@inherits Dynamicweb.Rendering.ViewModelTemplate @using System @using Dynamicweb.Ecommerce.ProductCatalog @MasterPageFile("Swift_Master.cshtml") @{ 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"; string schemaOrgProp = string.Empty; if(isArticlePagePage) { schemaOrgProp = "itemprop=\"articleBody\""; } string theme = ""; string gridContent = ""; string gridSidebar = Model.Grid("Sidebar", "Sidebar", "default:true;sort:1", "Page");; 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.Products.Product.GetProductById(productIdFromUrl); 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 (theme != "") {
@gridSidebar
@gridContent
} else {
@gridSidebar
@gridContent
} } else {
} 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 { } } else { } } }