Error executing template "Designs/Swift/_parsed/Swift_Page.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_eace6da770844bc391494facb0fabe71.ExecuteAsync()
at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
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>
@using System
@using Dynamicweb
@using Dynamicweb.Environment
@using Dynamicweb.Frontend
@functions {
string GetCookieOptInPermission(string category)
{
bool categoryOrAllGranted = false;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
}
return categoryOrAllGranted ? "granted" : "denied";
}
bool AllowTracking()
{
bool allowTracking = true;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
allowTracking = consentAtLeastOne;
}
return allowTracking;
}
}
@{
var cartSummaryPageId = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Model.Area.ID, "CartSummary")?.ID;
bool enableMiniCart = Model.Area.Item?.GetBoolean("EnableOffcanvasMiniCart") ?? false;
var offcanvasMiniCartBehaviour = Model.Area.Item?.GetRawValueString("OffcanvasMinicartBehaviour", "3") ?? "3";
bool miniCartEnabled = cartSummaryPageId != null && enableMiniCart;
var brandingPageId = Model.Area.Item?.GetInt32("BrandingPage") ?? 0;
var themePageId = Model.Area.Item?.GetInt32("ThemesPage") ?? 0;
var cssPageId = Model.Area.Item?.GetInt32("CssPage") ?? 0;
var brandingPage = brandingPageId != 0 ? Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null : null;
var themesParagraphs = themePageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(themePageId) ?? null : null;
var cssParagraphs = cssPageId != 0 ? Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(cssPageId) ?? null : null;
}
@if (themesParagraphs != null || brandingPage != null)
{
string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
bool renderAsResponsive = Model.Area.Item.GetString("DeviceRendering", "responsive").Equals("responsive", StringComparison.OrdinalIgnoreCase);
bool renderMobile = Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile || Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Tablet;
string responsiveClassDesktop = string.Empty;
string responsiveClassMobile = string.Empty;
if (renderAsResponsive)
{
responsiveClassDesktop = " d-none d-xl-block";
responsiveClassMobile = " d-block d-xl-none";
}
var headerDesktopLink = Model.Area.Item?.GetLink("HeaderDesktop") ?? null;
var headerMobileLink = Model.Area.Item?.GetLink("HeaderMobile") ?? null;
var footerDesktopLink = Model.Area.Item?.GetLink("FooterDesktop") ?? null;
var footerMobileLink = Model.Area.Item?.GetLink("FooterMobile") ?? null;
var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
string customHeaderInclude = !string.IsNullOrEmpty(Model.Area.Item.GetRawValueString("CustomHeaderInclude")) ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
var cssThemeAndBrandingStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"));
if (cssPageId != 0)
{
var cssFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_css_styles_{Model.Area.ID}.css"));
var cssParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(cssPageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < cssParagraphLastChanged.Audit.LastModifiedAt)
{
var cssPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(cssPageId);
cssPageview.Redirect = false;
cssPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < brandingPage.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (brandingPageId > 0)
{
var brandingPageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(brandingPageId);
brandingPageview.Redirect = false;
brandingPageview.Output();
}
}
if (!cssThemeAndBrandingStyleFileInfo.Exists || cssThemeAndBrandingStyleFileInfo.LastWriteTime < themesParagraphLastChanged.Audit.LastModifiedAt)
{
//Branding page has been saved or the file is missing. Rewrite the file to disc.
if (themePageId > 0)
{
var themePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(themePageId);
themePageview.Redirect = false;
themePageview.Output();
}
}
// Schema.org details for PDP
bool isProductDetailsPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("ProductID");
bool isArticlePage = Model.ItemType == "Swift_Article";
string schemaOrgType = string.Empty;
if (isProductDetailsPage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
}
if (isArticlePage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
}
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string favicon = Model.Area.Item.GetRawValueString("Favicon", "/Files/Templates/Designs/Swift/Assets/Images/favicon.png");
string appleTouchIcon = Model.Area.Item.GetRawValueString("AppleTouchIcon", "/Files/Templates/Designs/Swift/Assets/Images/apple-touch-icon.png");
string headerCssClass = "sticky-top";
bool movePageBehind = false;
if (Model.PropertyItem != null)
{
headerCssClass = Model.PropertyItem.GetRawValueString("MoveThisPageBehindTheHeader", "sticky-top");
movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false;
}
headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass;
headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass;
string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID").Trim();
string googleAnalyticsMeasurementID = Model.Area.Item.GetString("GoogleAnalyticsMeasurementID").Trim();
bool allowTracking = AllowTracking();
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/css/styles.css?{cssStyleFileInfo.LastWriteTime.Ticks}>; rel=preload; as=style;");
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;");
Dynamicweb.Context.Current.Response.AddHeader("link", $"</Files/Templates/Designs/Swift/Assets/js/scripts.js?{jsFileInfo.LastWriteTime.Ticks}>; rel=preload; as=script;");
SetMetaTags();
List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>();
var masterPage = Pageview.Area.IsMaster ? Pageview.Page : Pageview.Page.MasterPage;
languages.Add(masterPage);
if (masterPage?.Languages != null)
{
foreach (var language in masterPage.Languages)
{
languages.Add(language);
}
}
Uri url = Dynamicweb.Context.Current.Request.Url;
string hostName = url.Host;
<!doctype html>
<html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
<head>
<!-- @swiftVersion -->
@* Required meta tags *@
<meta charset="utf-8">
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="@favicon">
<link rel="apple-touch-icon" href="@appleTouchIcon">
@Model.MetaTags
@{
var alreadyWrittenTwoletterIsos = new List<string>();
@* Languages meta data *@
foreach (var language in languages)
{
hostName = url.Host;
if (language?.Area != null)
{
if (language.Area?.MasterArea != null && !string.IsNullOrEmpty(language.Area.MasterArea.DomainLock))
{
hostName = language.Area.MasterArea.DomainLock; //dk.domain.com or dk-domain.dk
}
if (language != null && language.Area != null && language.Published && language.Area.Active && language.Area.Published)
{
if (!string.IsNullOrEmpty(language.Area.DomainLock))
{
hostName = language.Area.DomainLock; //dk.domain.com or dk-domain.dk
}
string querystring = $"Default.aspx?ID={language.ID}";
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["GroupID"]))
{
querystring += $"&GroupID={Dynamicweb.Context.Current.Request.QueryString["GroupID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
querystring += $"&ProductID={Dynamicweb.Context.Current.Request.QueryString["ProductID"]}";
}
if (!string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["VariantID"]))
{
querystring += $"&VariantID={Dynamicweb.Context.Current.Request.QueryString["VariantID"]}";
}
string friendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(querystring);
if (language.Area.RedirectFirstPage && language.ParentPageId == 0 && language.Sort == 1)
{
friendlyUrl = "/";
}
string href = $"{url.Scheme}://{hostName}{friendlyUrl}";
<link rel="alternate" hreflang="@language.Area.CultureInfo.Name.ToLower()" href="@href">
if (!alreadyWrittenTwoletterIsos.Contains(language.Area.CultureInfo.TwoLetterISOLanguageName))
{
alreadyWrittenTwoletterIsos.Add(language.Area.CultureInfo.TwoLetterISOLanguageName);
<link rel="alternate" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName.ToLower()" href="@href">
}
}
}
}
}
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
@if (disableWideBreakpoints != "disableBoth")
{
<style>
@@media ( min-width: 1600px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1520px;
}
}
</style>
if (disableWideBreakpoints != "disableUltraWideOnly")
{
<style>
@@media ( min-width: 1920px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1820px;
}
}
</style>
}
}
@* Branding and Themes min stylesheet *@
<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">
<script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
<script type="module">
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
//Only load if AOS
const aosColumns = document.querySelectorAll('[data-aos]');
if (aosColumns.length > 0) {
swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
document.addEventListener('load.swift.assetloader', function () {
AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
});
}
</script>
@* Google gtag method - always include even if it is not used for anything *@
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
</script>
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID))
{
<script>
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
</script>
if (allowTracking)
{
string adConsent = GetCookieOptInPermission("Marketing");
string analyticsConsent = GetCookieOptInPermission("Statistical");
<script>
gtag('consent', 'update', {
'ad_storage': '@adConsent',
'ad_user_data': '@adConsent',
'ad_personalization': '@adConsent',
'analytics_storage': '@analyticsConsent'
});
</script>
}
}
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
<script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
<script>
gtag('js', new Date());
gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
</script>
}
@if (!string.IsNullOrWhiteSpace(customHeaderInclude))
{
@RenderPartial($"Components/Custom/{customHeaderInclude}")
}
</head>
<body class="brand @(masterTheme)" id="page@(Model.ID)">
@if (Pageview.Area.ID == 10 && allowTracking) {
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://load.sgtm.duka.dk/ns.html?id=GTM-MDDRFFW" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
}
@if (Pageview.Area.ID == 13 && allowTracking)
{
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://load.sgtm.dukatale.dk/ns.html?id=GTM-5GPXJ24S" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
}
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking && 1 == 2)
{
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
}
@if (renderAsResponsive || !renderMobile)
{
<header class="page-header @headerCssClass top-0@(responsiveClassDesktop)" id="page-header-desktop">
@if (headerDesktopLink != null)
{
@RenderGrid(headerDesktopLink.PageId)
}
</header>
}
@if ((renderAsResponsive || renderMobile))
{
<header class="page-header @headerCssClass top-0@(responsiveClassMobile)" id="page-header-mobile">
@if (headerMobileLink != null)
{
@RenderGrid(headerMobileLink.PageId)
}
</header>
}
<div data-intersect></div>
<main id="content" @(schemaOrgType)>
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using System
@using Dynamicweb.Ecommerce.ProductCatalog
@{
string productIdFromUrl = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : string.Empty;
bool isProductDetail = !string.IsNullOrEmpty(productIdFromUrl) && Pageview.Page.NavigationTag.ToLower() == "shop";
bool isArticlePagePage = Model.ItemType == "Swift_Article";
bool isArticleListPage = Model.ItemType == "Swift_ArticleListPage";
string schemaOrgProp = string.Empty;
if(isArticlePagePage)
{
schemaOrgProp = "itemprop=\"articleBody\"";
}
string theme = "";
string gridContent = "";
if (Model.PropertyItem != null)
{
theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? "theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
}
if (Model.Item != null || Pageview.IsVisualEditorMode)
{
if (!isProductDetail)
{
gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
}
else
{
var productObject = Dynamicweb.Ecommerce.Services.Products.GetProductById(productIdFromUrl, "", Pageview.Area.EcomLanguageId);
var detailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productObject.PrimaryGroupId)?.Meta.PrimaryPage ?? string.Empty;
var detailPageId = detailPage != string.Empty ? Convert.ToInt16(detailPage.Substring(detailPage.LastIndexOf('=') + 1)) : GetPageIdByNavigationTag("ProductDetailPage");
@RenderGrid(detailPageId)
}
}
bool doNotRenderPage = false;
//Check if we are on the poduct detail page, and if there is data to render
ProductViewModel product = new ProductViewModel();
if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
{
product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
if (string.IsNullOrEmpty(product.Id)) {
doNotRenderPage = true;
}
}
//Render the page
if (!doNotRenderPage) {
string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
if (Pageview.IsVisualEditorMode) {
@Model.Placeholder("dwcontent", "content", "default:true;sort:1")
}
<div class="@theme @itemIdentifier" @schemaOrgProp>
@if (isArticleListPage)
{
var hx = $"hx-get=\"{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Model.ID)}\" hx-select=\"#content\" hx-target=\"#content\" hx-swap=\"outerHTML\" hx-trigger=\"change\" hx-headers='{{\"feed\": \"true\"}}' hx-push-url=\"true\" hx-indicator=\"#ArticleFacetForm\"";
<form @hx id="ArticleFacetForm">
@gridContent
</form>
<script type="module" src="/Files/Templates/Designs/Swift/Assets/js/htmx.js"></script>
<script type="module">
document.addEventListener('htmx:confirm', (event) => {
let filters = event.detail.elt.querySelectorAll('select');
for (var i = 0; i < filters.length; i++) {
let input = filters[i];
if (input.name && !input.value) {
input.name = '';
}
}
});
document.addEventListener('htmx:beforeOnLoad', (event) => {
swift.Scroll.stopIntersectionObserver();
});
document.addEventListener('htmx:afterOnLoad', () => {
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
});
</script>
}
else
{
@gridContent
}
</div>
} else {
<div class="container">
<div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
</div>
}
if (!Model.IsCurrentUserAllowed)
{
int signInPage = GetPageIdByNavigationTag("SignInPage");
int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
if (!Pageview.IsVisualEditorMode)
{
if (signInPage != 0)
{
if (signInPage != Model.ID) {
Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
} else {
if (dashboardPage != 0) {
Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
} else {
Dynamicweb.Context.Current.Response.Redirect("/");
}
}
}
else
{
<div class="alert alert-dark m-0" role="alert">
<span>@Translate("You do not have access to this page")</span>
</div>
}
}
else
{
<div class="alert alert-dark m-0" role="alert">
<span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
</div>
}
}
}
</main>
@if (renderAsResponsive || !renderMobile)
{
<footer class="page-footer@(responsiveClassDesktop)" id="page-footer-desktop">
@if (footerDesktopLink != null)
{
@RenderGrid(footerDesktopLink.PageId)
}
</footer>
}
@if (renderAsResponsive || renderMobile)
{
<footer class="page-footer@(responsiveClassMobile)" id="page-footer-mobile">
@if (footerMobileLink != null)
{
@RenderGrid(footerMobileLink.PageId)
}
</footer>
}
@* Render any offcanvas menu here *@
@RenderSnippet("offcanvas")
@{
bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]);
}
@* Language selector modal *@
<div class="modal fade" id="PreferencesModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm" id="PreferencesModalContent">
@* The content here comes from an external request *@
</div>
</div>
@* Favorite toast *@
<div aria-live="polite" aria-atomic="true">
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
<div id="favoriteNotificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">@Translate("Favorite list updated")</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body d-flex gap-3">
<div id="favoriteNotificationToast_Image"></div>
<div id="favoriteNotificationToast_Text"></div>
</div>
</div>
</div>
</div>
@* Modal for dynamic content *@
<div class="modal fade js-product" id="DynamicModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-md">
<div class="modal-content theme light" id="DynamicModalContent">
@* The content here comes from an external request *@
</div>
</div>
</div>
@* Offcanvas for dynamic content *@
<div class="offcanvas offcanvas-end theme light" tabindex="-1" id="DynamicOffcanvas">
@* The content here comes from an external request *@
</div>
@if (Model.Area.Item.GetBoolean("ShowErpDownMessage") && !Dynamicweb.Core.Converter.ToBoolean(Context.Current.Items["IsWebServiceConnectionAvailable"]))
{
string erpDownMessageTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("ErpDownMessageTheme")) ? " theme " + Model.Area.Item.GetRawValueString("ErpDownMessageTheme").Replace(" ", "").Trim().ToLower() : "theme light";
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1040">
<div class="toast fade show border-0 @erpDownMessageTheme" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">@Translate("Connection down")</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
@Translate("We are experiencing some connectivity issues. Not all features may be available to you.")
</div>
</div>
</div>
}
@if (miniCartEnabled)
{
@* Open MiniCart when the cart is updated *@
<script type="module">
document.addEventListener('updated.swift.cart', (event) => {
let orderContext = event?.detail?.formData?.get("OrderContext");
updateCartSummary(orderContext);
@if (offcanvasMiniCartBehaviour == "2" || offcanvasMiniCartBehaviour == "3") {
<text>openMiniCartOffcanvas();</text>
}
});
</script>
if (offcanvasMiniCartBehaviour == "1" || offcanvasMiniCartBehaviour == "3")
{
@* Open MiniCart when toggle is clicked *@
<script type="module">
let miniCartToggles = document.querySelectorAll('.mini-cart-quantity');
miniCartToggles?.forEach((toggle) => {
toggle.parentElement.addEventListener('click', (event) => {
event.preventDefault();
let orderContext = toggle.dataset?.orderContext;
updateCartSummary(orderContext);
openMiniCartOffcanvas();
});
});
</script>
}
<script>
const updateCartSummary = (orderContext) => {
const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
swift.PageUpdater.UpdateFromUrlInline(event, '/Default.aspx?ID=@(cartSummaryPageId)&CartType=minicart&RequestPageID=@(Pageview.Page.ID)&OrderContext=' + orderContext +'', 'Swift_CartSummary.cshtml', dynamicOffcanvas);
};
const openMiniCartOffcanvas = () => {
const dynamicOffcanvas = document.getElementById('DynamicOffcanvas');
const miniCartOffcanvas = bootstrap.Offcanvas.getOrCreateInstance(dynamicOffcanvas);
dynamicOffcanvas.classList.add('overflow-y-auto');
if (!miniCartOffcanvas._isShown) {
miniCartOffcanvas.show();
hideActiveOffcanvases(miniCartOffcanvas);
}
};
const hideActiveOffcanvases = (miniCartOffcanvas) => {
let activeOffcanvases = document.querySelectorAll('.offcanvas.show');
activeOffcanvases?.forEach((offCanvas) => {
offCanvas = bootstrap.Offcanvas.getInstance(offCanvas);
if (offCanvas !== miniCartOffcanvas) {
offCanvas.hide();
}
});
};
</script>
}
</body>
</html>
}
else if (Pageview.IsVisualEditorMode)
{
<head>
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css" rel="stylesheet" media="all" type="text/css">
</head>
<body class="p-3">
<div class="alert alert-danger" role="alert">
@Translate("Basic Swift setup is needed!")
</div>
@if (brandingPage == null)
{
<div class="alert alert-warning" role="alert">
@Translate("Please add a Branding page and reference it in website settings")
</div>
}
@if (themesParagraphs == null)
{
<div class="alert alert-warning" role="alert">
@Translate("Please add a Themes collection page and reference it in website settings")
</div>
}
</body>
}
@functions {
void SetMetaTags()
{
//Verification Tokens
string siteVerificationGoogle = Model.Area.Item.GetString("Google_Site_Verification") != null ? Model.Area.Item.GetString("Google_Site_Verification") : "";
//Generic Site Values
string openGraphFacebookAppID = Model.Area.Item.GetString("Fb_app_id") != null ? Model.Area.Item.GetString("Fb_app_id") : "";
string openGraphType = Model.Area.Item.GetString("Open_Graph_Type") != null ? Model.Area.Item.GetString("Open_Graph_Type") : "";
string openGraphSiteName = Model.Area.Item.GetString("Open_Graph_Site_Name") != null ? Model.Area.Item.GetString("Open_Graph_Site_Name") : "";
string twitterCardSite = Model.Area.Item.GetString("Twitter_Site") != null ? Model.Area.Item.GetString("Twitter_Site") : "";
//Page specific values
string openGraphSiteTitle = Model.Area.Item.GetString("Open_Graph_Title") != null ? Model.Area.Item.GetString("Open_Graph_Title") : "";
FileViewModel openGraphImage = Model.Area.Item.GetFile("Open_Graph_Image");
string openGraphImageALT = Model.Area.Item.GetString("Open_Graph_Image_ALT") != null ? Model.Area.Item.GetString("Open_Graph_Image_ALT") : "";
string openGraphDescription = Model.Area.Item.GetString("Open_Graph_Description") != null ? Model.Area.Item.GetString("Open_Graph_Description") : "";
string twitterCardURL = Model.Area.Item.GetString("Twitter_URL") != null ? Model.Area.Item.GetString("Twitter_URL") : "";
string twitterCardTitle = Model.Area.Item.GetString("Twitter_Title") != null ? Model.Area.Item.GetString("Twitter_Title") : "";
string twitterCardDescription = Model.Area.Item.GetString("Twitter_Description") != null ? Model.Area.Item.GetString("Twitter_Description") : "";
FileViewModel twitterCardImage = Model.Area.Item.GetFile("Twitter_Image");
string twitterCardImageALT = Model.Area.Item.GetString("Twitter_Image_ALT") != null ? Model.Area.Item.GetString("Twitter_Image_ALT") : "";
string topImage = Pageview.Page.TopImage.StartsWith("/Files", StringComparison.OrdinalIgnoreCase) ? Pageview.Page.TopImage : $"/Files{Pageview.Page.TopImage}";
if (string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString["ProductID"]))
{
if (!string.IsNullOrEmpty(Model.Description))
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{Model.Description}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{openGraphDescription}\">");
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{topImage}\">");
Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{topImage}\">");
}
else if (openGraphImage != null)
{
Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
Pageview.Meta.AddTag($"<meta property=\"og:image:secure_url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}\">");
}
if (!string.IsNullOrEmpty(openGraphImageALT))
{
Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{openGraphImageALT}\">");
}
if (!string.IsNullOrEmpty(twitterCardDescription))
{
Pageview.Meta.AddTag("twitter:description", twitterCardDescription);
}
if (!string.IsNullOrEmpty(Pageview.Page.TopImage))
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{topImage}");
}
else if (twitterCardImage != null)
{
Pageview.Meta.AddTag("twitter:image", $"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{openGraphImage.Path}");
}
if (!string.IsNullOrEmpty(twitterCardImageALT))
{
Pageview.Meta.AddTag("twitter:image:alt", twitterCardImageALT);
}
}
if (!string.IsNullOrEmpty(siteVerificationGoogle))
{
Pageview.Meta.AddTag("google-site-verification", siteVerificationGoogle);
}
if (!string.IsNullOrEmpty(openGraphFacebookAppID))
{
Pageview.Meta.AddTag($"<meta property=\"fb:app_id\" content=\"{openGraphFacebookAppID}\">");
}
if (!string.IsNullOrEmpty(openGraphType))
{
Pageview.Meta.AddTag($"<meta property=\"og:type\" content=\"{openGraphType}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:url\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Pageview.SearchFriendlyUrl}\">");
}
if (!string.IsNullOrEmpty(openGraphSiteName))
{
Pageview.Meta.AddTag($"<meta property=\"og:site_name\" content=\"{openGraphSiteName}\">");
}
if (!string.IsNullOrEmpty(Model.Title))
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{Model.Title}\">");
}
else
{
Pageview.Meta.AddTag($"<meta property=\"og:title\" content=\"{openGraphSiteTitle}\">");
}
if (!string.IsNullOrEmpty(twitterCardSite))
{
Pageview.Meta.AddTag("twitter:site", twitterCardSite);
}
if (!string.IsNullOrEmpty(twitterCardURL))
{
Pageview.Meta.AddTag("twitter:url", twitterCardURL);
}
if (!string.IsNullOrEmpty(twitterCardTitle))
{
Pageview.Meta.AddTag("twitter:title", twitterCardTitle);
}
}
}