Error executing template "Designs/Swift/_parsed/Swift_Page_Custom.parsed.cshtml"
System.ArgumentException: Page ID must be greater than 0, but it was 0
   at Dynamicweb.Core.Ensure.That[TException](Boolean condition, String message)
   at Dynamicweb.Content.ParagraphService.GetParagraphsByPageId(Int32 pageId, ParagraphSort sortBy)
   at Dynamicweb.Frontend.Content.GetParagraphs(Int32 pageId)
   at Dynamicweb.Frontend.Content.CreateGridContent(Int32 contentId, Boolean ignoreVisualEdit)
   at Dynamicweb.Frontend.Content.RenderExternalGrid(Int32 pageId, String container)
   at CompiledRazorTemplates.Dynamic.RazorEngine_e49c101498a04da7a262147d21124141.Execute() in D:\dynamicweb.net\Solutions\Co3\itools.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\_parsed\Swift_Page_Custom.parsed.cshtml:line 292
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 2 @using System 3 @using Dynamicweb 4 @using Dynamicweb.Environment 5 @using Dynamicweb.Frontend 6 7 @{ 8 string swiftVersion = ReadFile("~/Files/Templates/Designs/Swift/swift_version.txt"); 9 bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase); 10 bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet; 11 string responsiveClassDesktop = string.Empty; 12 string responsiveClassMobile = string.Empty; 13 if (renderAsResponsive) 14 { 15 responsiveClassDesktop = " d-none d-xl-block"; 16 responsiveClassMobile = " d-block d-xl-none"; 17 } 18 19 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 20 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0; 21 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty; 22 23 var brandingPage = Dynamicweb.Services.Pages?.GetPage(brandingPageId) ?? null; 24 var themesParagraphLastChanged = Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault(); 25 26 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt; 27 var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"~/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css")); 28 29 // Schema.org details for PDP 30 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 31 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 32 bool isArticlePage = Model.ItemType == "Swift_Article"; 33 string schemaOrgType = string.Empty; 34 35 if(isProductDetailsPage) 36 { 37 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\""; 38 } 39 40 if(isArticlePage) 41 { 42 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\""; 43 } 44 45 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt) 46 { 47 //Branding page has been saved or the file is missing. Rewrite the file to disc. 48 if (brandingPageId > 0) 49 { 50 var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId); 51 brandingPageview.Redirect = false; 52 brandingPageview.Output(); 53 } 54 } 55 56 if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt) 57 { 58 //Branding page has been saved or the file is missing. Rewrite the file to disc. 59 if (themePageId > 0) 60 { 61 var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId); 62 themePageview.Redirect = false; 63 themePageview.Output(); 64 } 65 } 66 67 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/css/styles.css")); 68 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("~/Files/Templates/Designs/Swift/Assets/js/scripts.js")); 69 70 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 71 72 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "~/Files/Templates/Designs/Swift/Assets/Images/favicon.png"; 73 74 string headerCssClass = "sticky-top"; 75 bool movePageBehind = false; 76 77 if (Pageview.Page.PropertyItem != null) 78 { 79 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 80 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false; 81 } 82 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 83 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 84 85 string googleAnalyticsTrackingID = Model.Area.Item.GetString("GoogleAnalyticsTrackingID"); 86 string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID"); 87 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 88 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 89 90 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;"); 91 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css?{cssLastModified.Ticks}; rel=preload; as=style;"); 92 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/aos.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 93 Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}; rel=preload; as=script;"); 94 //Dynamicweb.Context.Current.Response.Flush(); //This sends the headers where we are now in the rendering making the TTFB faster 95 96 SetMetaTags(); 97 98 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 99 100 if (Pageview.Area.IsMaster) 101 { 102 languages.Add(Pageview.Page); 103 if (Pageview.Page.Languages != null) 104 { 105 foreach (var language in Pageview.Page.Languages) 106 { 107 languages.Add(language); 108 } 109 } 110 } 111 else 112 { 113 languages.Add(Pageview.Page.MasterPage); 114 if (Pageview.Page.MasterPage != null) 115 { 116 if (Pageview.Page.MasterPage.Languages != null) 117 { 118 foreach (var language in Pageview.Page.MasterPage.Languages) 119 { 120 languages.Add(language); 121 } 122 } 123 } 124 } 125 126 string siteLanguage = Pageview.Area.CultureInfo.Name; 127 Uri url = Dynamicweb.Context.Current.Request.Url; 128 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 129 130 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries(); 131 var ecomCurrencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies(); 132 } 133 <!doctype html> 134 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 135 <head> 136 <!-- @swiftVersion --> 137 <!-- Google Tag Manager --> 138 <script> 139 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 140 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 141 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 142 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 143 })(window,document,'script','dataLayer','GTM-WDK74GS'); 144 </script> 145 <!-- End Google Tag Manager --> 146 @* Required meta tags *@ 147 <meta charset="utf-8"> 148 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0"> 149 <link rel="shortcut icon" href="@favicon"> 150 <link rel="apple-touch-icon" href="~/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png"> 151 152 @Model.MetaTags 153 154 @{ 155 @* Languages meta data *@ 156 foreach (var language in languages) 157 { 158 if (language?.Area != null) 159 { 160 if (language != null && language.Published && language.Active && language.Area.Active && language.Area.Published && language.Area.ID != Dynamicweb.Frontend.PageView.Current().AreaID) 161 { 162 if (!string.IsNullOrEmpty(language.Area.DomainLock)) 163 { 164 hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk 165 } 166 string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(language.ID); 167 string href = $"{url.Scheme}://{hostName}{friendlyUrl}"; 168 169 <link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href" /> 170 } 171 } 172 } 173 } 174 175 <title>@Model.Title</title> 176 @* Bootstrap + Swift stylesheet *@ 177 <link href="~/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css"> 178 @* Branding and Themes min stylesheet *@ 179 <link href="~/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_@(Model.Area.ID).min.css?@cssLastModified.Ticks" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified"> 180 <script src="~/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 181 <script src="~/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 182 183 <script type="module"> 184 AOS.init({ offset: 0, duration: 400, delay: 100, easing: 'ease-in-out', mirror: true, disable: window.matchMedia('(prefers-reduced-motion: reduce)') }); 185 swift.Scroll.hideHeadersOnScroll(); 186 swift.Scroll.handleAlternativeTheme(); 187 </script> 188 189 @* Global site tag (gtag.js) - Google Analytics *@ 190 @if (!string.IsNullOrWhiteSpace(googleAnalyticsTrackingID)) 191 { 192 <script src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsTrackingID" async></script> 193 <script> 194 window.dataLayer = window.dataLayer || []; 195 function gtag() { window.dataLayer.push(arguments); } 196 gtag('js', new Date()); 197 gtag('config', '@googleAnalyticsTrackingID'); 198 </script> 199 } 200 201 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID)) 202 { 203 var GoogleAnalyticsDebugMode = ""; 204 bool isLoggedInBackendUser = false; 205 206 if (Dynamicweb.Environment.ExecutingContext.IsAdminLoggedIn()) { 207 isLoggedInBackendUser = true; 208 } 209 210 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && @isLoggedInBackendUser) 211 { 212 GoogleAnalyticsDebugMode = ", {'debug_mode': true}"; 213 } 214 215 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script> 216 <script> 217 window.dataLayer = window.dataLayer || []; 218 function gtag(){dataLayer.push(arguments);} 219 gtag('js', new Date()); 220 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode); 221 </script> 222 } 223 224 @if (!string.IsNullOrWhiteSpace(customHeaderInclude)) 225 { 226 @RenderPartial($"Components/Custom/{customHeaderInclude}") 227 } 228 </head> 229 <body class="brand @(masterTheme)" id="page@(Model.ID)"> 230 <!-- Google Tag Manager (noscript) --> 231 <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WDK74GS" 232 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> 233 <!-- End Google Tag Manager (noscript) --> 234 @if (renderAsResponsive || !renderMobile) 235 { 236 <header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop"> 237 @if (@Model.Area.Item.GetLink("HeaderDesktop") != null) 238 { 239 @RenderGrid(@Model.Area.Item.GetLink("HeaderDesktop").PageId) 240 } 241 </header> 242 } 243 244 @if ((renderAsResponsive || renderMobile)) 245 { 246 <header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile"> 247 @if (@Model.Area.Item.GetLink("HeaderMobile") != null) 248 { 249 @RenderGrid(@Model.Area.Item.GetLink("HeaderMobile").PageId) 250 } 251 </header> 252 } 253 254 <main id="content" @(schemaOrgType)> 255 <div data-intersect></div> 256 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 257 @using System 258 @using Dynamicweb.Ecommerce.ProductCatalog 259 260 261 @{ 262 string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty; 263 bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop"; 264 265 bool isArticlePagePage = Model.ItemType == "Swift_Article"; 266 string schemaOrgProp = string.Empty; 267 if(isArticlePagePage) 268 { 269 schemaOrgProp = "itemprop=\"articleBody\""; 270 } 271 272 string theme = ""; 273 string gridContent = ""; 274 275 if (Model.PropertyItem != null) 276 { 277 theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? " theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 278 } 279 280 if (Model.Item != null || Pageview.IsVisualEditorMode) 281 { 282 if (!isProductDetail) 283 { 284 gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page"); 285 } 286 else 287 { 288 var productObject = Dynamicweb.Ecommerce.Products.Product.GetProductById(productIdFromUrl); 289 var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty; 290 var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage"); 291 292 @RenderGrid(detailPageId) 293 } 294 } 295 296 bool doNotRenderPage = false; 297 298 //Check if we are on the poduct detail page, and if there is data to render 299 ProductViewModel product = new ProductViewModel(); 300 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 301 { 302 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 303 if (string.IsNullOrEmpty(product.Id)) { 304 doNotRenderPage = true; 305 } 306 } 307 308 //Render the page 309 if (!doNotRenderPage) { 310 string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page"; 311 312 if (theme != "") 313 { 314 <div class="@theme item_@itemIdentifier" @schemaOrgProp> 315 @gridContent 316 </div> 317 } 318 else 319 { 320 <div class="item_@itemIdentifier" @schemaOrgProp> 321 @gridContent 322 </div> 323 } 324 } else { 325 <div class="container"> 326 <div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div> 327 </div> 328 } 329 330 if (!Model.IsCurrentUserAllowed) 331 { 332 int signInPage = GetPageIdByNavigationTag("SignInPage"); 333 int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage"); 334 335 if (!Pageview.IsVisualEditorMode) 336 { 337 if (signInPage != 0) 338 { 339 if (signInPage != Model.ID) { 340 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage); 341 } else { 342 if (dashboardPage != 0) { 343 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage); 344 } else { 345 Dynamicweb.Context.Current.Response.Redirect("/"); 346 } 347 } 348 } 349 else 350 { 351 <div class="alert alert-dark m-0" role="alert"> 352 <span>@Translate("You do not have access to this page")</span> 353 </div> 354 } 355 } 356 else 357 { 358 <div class="alert alert-dark m-0" role="alert"> 359 <span>@Translate("To work on this page, you must be signed in, in the frontend")</span> 360 </div> 361 } 362 } 363 } 364 365 </main> 366 367 @if (renderAsResponsive || !renderMobile) 368 { 369 <footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop"> 370 @if (@Model.Area.Item.GetLink("FooterDesktop") != null) 371 { 372 @RenderGrid(@Model.Area.Item.GetLink("FooterDesktop").PageId) 373 } 374 </footer> 375 } 376 377 @if (renderAsResponsive || renderMobile) 378 { 379 <footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile"> 380 @if (@Model.Area.Item.GetLink("FooterMobile") != null) 381 { 382 @RenderGrid(@Model.Area.Item.GetLink("FooterMobile").PageId) 383 } 384 </footer> 385 } 386 387 @* Render any offcanvas menu here *@ 388 @RenderSnippet("offcanvas") 389 390 @{ 391 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 392 } 393 394 @* Language selector modal *@ 395 @if (languages.Count > 1 || ecomCountries.Count > 1 || ecomCurrencies.Count() > 1) 396 { 397 <div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true"> 398 <div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent"> 399 @* The content here comes from an external request *@ 400 </div> 401 </div> 402 } 403 404 @* Favorite toast *@ 405 <div aria-live="polite" aria-atomic="true"> 406 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11"> 407 <div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true"> 408 <div class="toast-header"> 409 <strong class="me-auto">@Translate("Favorite list updated")</strong> 410 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> 411 </div> 412 <div class="toast-body d-flex gap-3"> 413 <div id="favoriteNotificationToast_Image"></div> 414 <div id="favoriteNotificationToast_Text"></div> 415 </div> 416 </div> 417 </div> 418 </div> 419 420 @* Modal for dynamic content *@ 421 <div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true"> 422 <div class="modal-dialog modal-dialog-centered modal-md"> 423 <div class="modal-content theme light" id="DynamicModalContent"> 424 @* The content here comes from an external request *@ 425 </div> 426 </div> 427 </div> 428 429 @* Offcanvas for dynamic content *@ 430 <div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas" style="width: 30rem"> 431 @* The content here comes from an external request *@ 432 </div> 433 434 @if (isErpConnectionDown && Model.Area.Item.GetBoolean("ShowErpDownMessage")) 435 { 436 string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light"; 437 438 <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040"> 439 <div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true"> 440 <div class="toast-header"> 441 <strong class="me-auto">@Translate("Connection down")</strong> 442 <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> 443 </div> 444 <div class="toast-body"> 445 @Translate("We are experiencing some connectivity issues. Not all features may be available to you.") 446 </div> 447 </div> 448 </div> 449 } 450 </body> 451 </html> 452 @functions { 453 454 void SetMetaTags() 455 { 456 //Verification Tokens 457 string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : ""; 458 //string siteVerificationYandex = Model.Area.Item.GetString("Yandex_Verification") != null ? Model.Area.Item.GetString("Yandex_Verification") : ""; 459 //string siteVerificationMS = Model.Area.Item.GetString("Msvalidate_01") != null ? Model.Area.Item.GetString("Msvalidate_01") : ""; 460 //string siteVerificationAlexa = Model.Area.Item.GetString("AlexaVerifyID") != null ? Model.Area.Item.GetString("AlexaVerifyID") : ""; 461 //string siteVerificationPinterest = Model.Area.Item.GetString("P_domain_verify") != null ? Model.Area.Item.GetString("P_domain_verify") : ""; 462 //string siteVerificationNorton = Model.Area.Item.GetString("Norton_safeweb_site_verification") != null ? Model.Area.Item.GetString("Norton_safeweb_site_verification") : ""; 463 464 //Generic Site Values 465 string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : ""; 466 string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : ""; 467 string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : ""; 468 469 string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : ""; 470 471 //Page specific values 472 string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : ""; 473 FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image"); 474 string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : ""; 475 string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : ""; 476 477 string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : ""; 478 string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : ""; 479 string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : ""; 480 FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image"); 481 string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : ""; 482 483 if (!string.IsNullOrEmpty(siteVerificationGoogle)) 484 { 485 Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle); 486 } 487 488 if (!string.IsNullOrEmpty(openGraphFacebookAppID)) 489 { 490 Pageview.Meta.AddTag("fb:app_id", openGraphFacebookAppID); 491 } 492 493 if (!string.IsNullOrEmpty(openGraphType)) 494 { 495 Pageview.Meta.AddTag("og:type", openGraphType); 496 } 497 498 if (!string.IsNullOrEmpty(openGraphSiteName)) 499 { 500 Pageview.Meta.AddTag("og:site_name", openGraphSiteName); 501 } 502 if (!string.IsNullOrEmpty(Model.Title)) 503 { 504 Pageview.Meta.AddTag("og:title", Model.Title); 505 } 506 else 507 { 508 Pageview.Meta.AddTag("og:title", openGraphSiteTitle); 509 } 510 511 512 if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"])) 513 { 514 if (!string.IsNullOrEmpty(Model.Description)) 515 { 516 Pageview.Meta.AddTag("og:description", Model.Description); 517 } 518 else 519 { 520 Pageview.Meta.AddTag("og:description", openGraphDescription); 521 } 522 if (openGraphImage != null) 523 { 524 Pageview.Meta.AddTag("og:image", openGraphImage.Path); 525 } 526 527 if (!string.IsNullOrEmpty(openGraphImageALT)) 528 { 529 Pageview.Meta.AddTag("og:image:alt", openGraphImageALT); 530 } 531 if (!string.IsNullOrEmpty(twitterCardDescription)) 532 { 533 Pageview.Meta.AddTag("twitter:description", twitterCardDescription); 534 } 535 536 if (twitterCardImage != null) 537 { 538 Pageview.Meta.AddTag("twitter:image", twitterCardImage.Path); 539 } 540 541 if (!string.IsNullOrEmpty(twitterCardImageALT)) 542 { 543 Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT); 544 } 545 } 546 547 if (!string.IsNullOrEmpty(twitterCardSite)) 548 { 549 Pageview.Meta.AddTag("twitter:site", twitterCardSite); 550 } 551 552 if (!string.IsNullOrEmpty(twitterCardURL)) 553 { 554 Pageview.Meta.AddTag("twitter:url", twitterCardURL); 555 } 556 557 if (!string.IsNullOrEmpty(twitterCardTitle)) 558 { 559 Pageview.Meta.AddTag("twitter:title", twitterCardTitle); 560 } 561 } 562 } 563