Error executing template "Designs/Publications/Publication_Catalog.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_e33f5704e10348da85f6b5989f136f81.<>c.<GenerateSubCatalogPages>b__12_1(ProductViewModel p)
at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.GroupByIterator`2.ToList()
at CompiledRazorTemplates.Dynamic.RazorEngine_e33f5704e10348da85f6b5989f136f81.GenerateSubCatalogPages(IEnumerable`1 subCatalogPages, String productId, String variantId)
at CompiledRazorTemplates.Dynamic.RazorEngine_e33f5704e10348da85f6b5989f136f81.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.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, 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 RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, 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>
@functions {
public Dynamicweb.Frontend.PageInfoViewModel? GetParentLayoutFolderPage(int pageId)
{
var parentPage = Dynamicweb.Content.Services.Pages.GetPage(pageId)?.Parent ?? null;
if (parentPage != null) {
var parentViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(parentPage);
if (parentPage.ItemType == "Publication_Folder" || parentPage.ItemType == "Publication_FolderWithLayouts") {
return parentViewModel;
} else {
return GetParentLayoutFolderPage(parentPage.ID);
}
}
else
{
return null;
}
}
}
@{
var stylePage = GetParentLayoutFolderPage(Model.ID);
var cssBasePath = "/Files/Templates/Designs/Publications/_parsed/css/";
bool triggerPrintDialog = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("print") ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("print")) : false;
triggerPrintDialog = Dynamicweb.Context.Current.Request.Form.AllKeys.Contains("print") ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form.Get("print")) : triggerPrintDialog;
var cssLastModified = stylePage?.UpdatedDate.Ticks;
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath($"{cssBasePath}{stylePage?.ID}_{Model.Area.ID}.min.css"));
Dynamicweb.Context.Current.Response.AddHeader("link", $"{cssBasePath}{stylePage?.ID}_{Model.Area.ID}.min.css?{cssLastModified}; rel=preload; as=style;");
Dynamicweb.Context.Current.Response.AddHeader("link", $"{cssBasePath}fonts_{Model?.Area?.ID}.min.css?{cssLastModified}; rel=preload; as=style;");
var pageFormat = stylePage?.Item.GetRawValueString("PageFormat", "a4-portrait");
@* CSS generation *@
if (!cssStyleFileInfo.Exists || cssStyleFileInfo.LastWriteTime < stylePage?.UpdatedDate)
{
if (stylePage?.ID > 0)
{
var stylePageview = Dynamicweb.Frontend.PageView.GetPageviewByPageID(stylePage.ID);
stylePageview.Redirect = false;
stylePageview.Output();
}
}
}
<!doctype html>
<html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
<head>
<meta charset="utf-8" />
<title>@(Model?.Title)</title>
<link href="/Files/Templates/Designs/Publications/Assets/css/publications.min.css" rel="stylesheet" type="text/css">
<link href="/Files/Templates/Designs/Publications/_parsed/css/fonts_@(Model?.Area.ID).min.css" rel="stylesheet" media="all" type="text/css">
<link href="@(cssBasePath)@(stylePage?.ID)_@(Model?.Area.ID).min.css?@cssLastModified" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified">
</head>
<body class="dwp-body @pageFormat">
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using Dynamicweb.Frontend
@using Dynamicweb.Ecommerce.ProductCatalog
@functions {
public int pageNumber { get; set; } = 0;
public class PublicationPage
{
public string? Title { get; set; }
public int PageID { get; set; } = 0;
public int PageNumber { get; set; } = 0;
public bool HideHeader { get; set; } = false;
public bool HideFooter { get; set; } = false;
public string? BackgroundColor { get; set; }
public string? FontColor { get; set; }
public ProductViewModel? Product { get; set; }
public List<ProductViewModel>? ProductList { get; set; }
public PublicationPageType Type { get; set; } = PublicationPageType.Content;
}
public class PublicationCatalog
{
public List<PublicationPage> Pages { get; set; } = new List<PublicationPage>();
}
public enum PublicationPageType
{
Content,
TableOfContent,
DataSheet,
ProductList,
RelatedList,
VariantList,
GroupInfo,
}
public PublicationPageType GetPageTypeByItemType(string itemType)
{
PublicationPageType publicationPageType = PublicationPageType.Content;
if (itemType == "Publication_ProductListContainer")
{
publicationPageType = PublicationPageType.ProductList;
}
if (itemType == "Publication_VariantListPage")
{
publicationPageType = PublicationPageType.VariantList;
}
if (itemType == "Publication_RelatedListPage")
{
publicationPageType = PublicationPageType.RelatedList;
}
if (itemType == "Publication_DataSheetPage")
{
publicationPageType = PublicationPageType.DataSheet;
}
if (itemType == "Publication_TableOfContentsPage")
{
publicationPageType = PublicationPageType.TableOfContent;
}
if (itemType == "Publication_GroupInfoPage") {
publicationPageType = PublicationPageType.GroupInfo;
}
return publicationPageType;
}
public String? GetSwatchColor(Dynamicweb.Content.Page page, string fieldName)
{
var colorService = new Dynamicweb.Content.Items.ColorSwatchService();
string? colorName = page.Item[fieldName]?.ToString() ?? string.Empty;
string? colorHex = colorName;
if (!string.IsNullOrWhiteSpace(colorName) && !colorName.StartsWith("#") && !"transparent".Equals(colorName, StringComparison.OrdinalIgnoreCase))
{
colorHex = colorService.GetHexColor(Pageview.AreaID, colorName);
}
return colorHex;
}
public PageInfoViewModel GetParentLayoutFolder(int pageId)
{
if (Dynamicweb.Content.Services.Pages.GetPage(pageId).Parent != null)
{
var parent = Dynamicweb.Content.Services.Pages.GetPage(pageId).Parent;
if (parent.ItemType == "Publication_Folder" || parent.ItemType == "Publication_FolderWithLayouts")
{
var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(parent);
return pageViewModel;
}
else
{
return GetParentLayoutFolder(parent.ID);
}
}
else
{
return null;
}
}
public List<PublicationPage> GenerateSubCatalogPages(IEnumerable<Dynamicweb.Content.Page> subCatalogPages, string? productId = null, string? variantId = null)
{
List<PublicationPage> subCatalog = new List<PublicationPage>();
PublicationPageType pageType = PublicationPageType.DataSheet;
foreach(var subPage in subCatalogPages) {
pageType = GetPageTypeByItemType(subPage.ItemType);
bool skipPageNumber = Convert.ToBoolean(subPage.Item["SkipPageNumber"]);
skipPageNumber = subPage.ItemType == "Publication_TableOfContentsPage" ? true : skipPageNumber;
bool hideHeader = Convert.ToBoolean(subPage.Item["HideHeaderOnThisPage"]);
bool hideFooter = Convert.ToBoolean(subPage.Item["HideFooterOnThisPage"]);
ProductViewModel product = new ProductViewModel();
List<ProductViewModel> productList = new List<ProductViewModel>();
if (Dynamicweb.Context.Current.Items.Contains("ProductList") && productId != null)
{
productList = (List<ProductViewModel>)Dynamicweb.Context.Current.Items["ProductList"];
foreach (var listProduct in productList)
{
if (listProduct.Id == productId && listProduct.VariantId == variantId || listProduct.Id == productId)
{
product = listProduct;
}
}
}
List<ProductViewModel> products = new List<ProductViewModel>();
if (subPage.ItemType == "Publication_ProductListPage" && Dynamicweb.Context.Current.Items.Contains("ProductList"))
{
pageType = PublicationPageType.ProductList;
productList = (List<ProductViewModel>)Dynamicweb.Context.Current.Items["ProductList"];
products = productList;
}
if (subPage.ItemType == "Publication_RelatedListPage")
{
pageType = PublicationPageType.RelatedList;
if (product != null && product.RelatedGroups != null)
{
products = product?.GetRelatedProducts()?.ToList();
}
}
if (subPage.ItemType == "Publication_VariantListPage")
{
pageType = PublicationPageType.VariantList;
if (product != null)
{
List<ProductInfoViewModel> variantProductInfos = new List<ProductInfoViewModel>();
foreach (var variant in product.VariantCombinations())
{
var productInfo = new ProductInfoViewModel()
{
ProductId = productId,
VariantId = variant
};
if (!string.IsNullOrEmpty(productInfo.VariantId))
{
variantProductInfos.Add(productInfo);
}
};
products = variantProductInfos.GetProducts()?.ToList();
}
}
List<ProductViewModel> subCatalogProducts = new List<ProductViewModel>();
List<ProductViewModel> productListSubList = new List<ProductViewModel>();
var repeaterParagraph = Dynamicweb.Content.Services.Paragraphs?.GetParagraphsByPageId(subPage.ID)?.FirstOrDefault(p => p.ItemType == "Publication_ListComponentParagraph");
int productsOnEachPage = repeaterParagraph != null ? Convert.ToInt32(repeaterParagraph.Item["ProductsOnEachPage"]) : 4;
int productOnPageCount = 1;
if (products?.Count > 0)
{
bool sortInGroups = repeaterParagraph?.Item["SortInGroups"] != null ? Convert.ToBoolean(repeaterParagraph.Item["SortInGroups"]) : false;
bool isFirstGroupPage = true;
bool isNewGroupPage = false;
string nextGroupId = string.Empty;
int totalProductsCount = products.Count;
int productCounter = 0;
var productsGrouped = products.GroupBy(p => p.PrimaryOrDefaultGroup.Id).ToList();
//Flatten the grouped products
foreach (var productGroup in productsGrouped) {
foreach (var listProduct in productGroup) {
subCatalogProducts.Add(listProduct);
}
}
var productForGroupPage = subCatalogProducts.FirstOrDefault();
foreach (var listProduct in subCatalogProducts)
{
productListSubList.Add(listProduct);
if (productOnPageCount <= (productsOnEachPage - 1))
{
productOnPageCount++;
}
else
{
productOnPageCount = 1;
}
if (sortInGroups) {
if (isFirstGroupPage) {
foreach(var topSubPage in subCatalogPages) {
if (topSubPage.ItemType == "Publication_GroupInfoPage") {
skipPageNumber = Convert.ToBoolean(subPage.Item["SkipPageNumber"]);
if (!skipPageNumber) {
pageNumber++;
}
subCatalog.Add(
new PublicationPage {
Title = !string.IsNullOrWhiteSpace(product.Title) ? product.Title : topSubPage.GetDisplayName(),
PageID = topSubPage.ID,
PageNumber = !skipPageNumber ? pageNumber : 0,
Product = productForGroupPage,
HideHeader = hideHeader,
HideFooter = hideFooter,
BackgroundColor = GetSwatchColor(topSubPage, "PageBackgroundColor"),
FontColor = GetSwatchColor(topSubPage, "PageFontColor"),
Type = PublicationPageType.GroupInfo
}
);
}
}
isFirstGroupPage = false;
}
if (productCounter < (totalProductsCount - 1)) {
nextGroupId = subCatalogProducts[productCounter + 1].PrimaryOrDefaultGroup.Id;
productForGroupPage = subCatalogProducts[productCounter + 1];
}
isNewGroupPage = (nextGroupId != listProduct.PrimaryOrDefaultGroup.Id && nextGroupId != string.Empty) ? true : false;
if (isNewGroupPage) {
productOnPageCount = 1;
}
}
if (productOnPageCount == 1 || productCounter == (totalProductsCount - 1))
{
List<ProductViewModel> productListForPage = new List<ProductViewModel>(productListSubList);
if (!skipPageNumber)
{
pageNumber++;
}
subCatalog.Add(
new PublicationPage
{
Title = !string.IsNullOrWhiteSpace(product.Title) ? product.Title : subPage.GetDisplayName(),
PageID = subPage.ID,
PageNumber = !skipPageNumber ? pageNumber : 0,
Product = product,
BackgroundColor = GetSwatchColor(subPage, "PageBackgroundColor"),
FontColor = GetSwatchColor(subPage, "PageFontColor"),
ProductList = productListForPage,
HideHeader = hideHeader,
HideFooter = hideFooter,
Type = pageType
}
);
productListSubList.Clear();
}
if (isNewGroupPage) {
foreach(var topSubPage in subCatalogPages) {
if (topSubPage.ItemType == "Publication_GroupInfoPage") {
skipPageNumber = Convert.ToBoolean(subPage.Item["SkipPageNumber"]);
if (!skipPageNumber) {
pageNumber++;
}
subCatalog.Add(
new PublicationPage {
Title = !string.IsNullOrWhiteSpace(product.Title) ? product.Title : topSubPage.GetDisplayName(),
PageID = topSubPage.ID,
PageNumber = !skipPageNumber ? pageNumber : 0,
Product = productForGroupPage,
HideHeader = hideHeader,
HideFooter = hideFooter,
BackgroundColor = GetSwatchColor(topSubPage, "PageBackgroundColor"),
FontColor = GetSwatchColor(topSubPage, "PageFontColor"),
Type = PublicationPageType.GroupInfo
}
);
}
}
}
productCounter++;
}
}
else if (subPage.ItemType == "Publication_DataSheetPage" || subPage.ItemType == "Publication_ContentPage" || subPage.ItemType == "Publication_TableOfContentsPage")
{
if (!skipPageNumber)
{
pageNumber++;
}
if (products?.Count > 0) {
var orderedList = products.OrderBy(p => p.PrimaryOrDefaultGroup.Id).ToList();
product = orderedList.FirstOrDefault();
}
subCatalog.Add(
new PublicationPage
{
Title = !string.IsNullOrWhiteSpace(product.Title) ? product.Title : subPage.GetDisplayName(),
PageID = subPage.ID,
PageNumber = !skipPageNumber ? pageNumber : 0,
Product = product,
HideHeader = hideHeader,
HideFooter = hideFooter,
BackgroundColor = GetSwatchColor(subPage, "PageBackgroundColor"),
FontColor = GetSwatchColor(subPage, "PageFontColor"),
Type = pageType
}
);
}
}
return subCatalog;
}
}
@{
string gridContent = Model.Grid("Grid", "Publication", "default:true;sort:1", "Publication_Page");
var layout = GetParentLayoutFolder(Model.ID);
var headerReference = layout != null && layout.Item.GetLink("Header") != null ? layout.Item.GetLink("Header").PageId : 0;
var footerReference = layout != null && layout.Item.GetLink("Footer") != null ? layout.Item.GetLink("Footer").PageId : 0;
var catalogPages = Dynamicweb.Content.Services.Pages.GetPagesByParentID(Model.ID).Where(p => p.Published == true).OrderBy(p => p.Sort);
PublicationCatalog fullCatalog = new PublicationCatalog();
foreach (var page in catalogPages)
{
bool hideHeader = Convert.ToBoolean(page.Item["HideHeaderOnThisPage"]);
bool hideFooter = Convert.ToBoolean(page.Item["HideFooterOnThisPage"]);
bool skipPageNumber = Convert.ToBoolean(page.Item["SkipPageNumber"]);
skipPageNumber = page.ItemType == "Publication_TableOfContentsPage" ? true : skipPageNumber;
if (page.ItemType == "Publication_ProductPages" || page.ItemType == "Publication_ProductListContainer")
{
IEnumerable<Dynamicweb.Content.Page> subCatalogPages = Dynamicweb.Content.Services.Pages.GetPagesByParentID(page.ID).Where(p => p.Published == true).OrderBy(p => p.Sort);
@* This secures that it is always the correct products that exist in the context items *@
<div class="dwp-exclude-in-print" style="display: none">
@RenderGrid(page.ID)
</div>
if (page.ItemType == "Publication_ProductPages" && Dynamicweb.Context.Current.Items.Contains("ProductList"))
{
List<ProductViewModel> allAvailableProducts = (List<ProductViewModel>)Dynamicweb.Context.Current.Items["ProductList"];
foreach (var product in allAvailableProducts)
{
fullCatalog.Pages.AddRange(GenerateSubCatalogPages(subCatalogPages, product.Id, product.VariantId));
}
}
else
{
fullCatalog.Pages.AddRange(GenerateSubCatalogPages(subCatalogPages));
}
}
else
{
if (!skipPageNumber)
{
pageNumber++;
}
PublicationPageType pageType = GetPageTypeByItemType(page.ItemType);
fullCatalog.Pages.Add(
new PublicationPage
{
Title = page.GetDisplayName(),
PageID = page.ID,
PageNumber = !skipPageNumber ? pageNumber : 0,
HideHeader = hideHeader,
HideFooter = hideFooter,
BackgroundColor = GetSwatchColor(page, "PageBackgroundColor"),
FontColor = GetSwatchColor(page, "PageFontColor"),
Type = pageType
}
);
}
}
int totalPages = pageNumber;
if (Dynamicweb.Context.Current.Items.Contains("TotalPages"))
{
Dynamicweb.Context.Current.Items["TotalPages"] = totalPages;
}
else
{
Dynamicweb.Context.Current.Items.Add("TotalPages", totalPages);
}
bool testPages = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("test") ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("Test")) : false;
}
<div style="display: none">
@gridContent
</div>
@* Catalog page testing code *@
@if (testPages && fullCatalog?.Pages != null)
{
<div class="dwp-test-page-list">
@foreach (var catalogPage in fullCatalog.Pages)
{
string title = $"{catalogPage.PageID} - {catalogPage.Title}";
title += !string.IsNullOrEmpty(catalogPage?.Product?.Id) ? $" ProductID: {catalogPage.Product.Id}" : "";
string pageType = catalogPage.Type.ToString();
<div class="dwp-test-page">
<div class="dwp-mb-1">
<div class="dwp-test-page-header dwp-fw-bold">@title</div>
<small>@pageType</small>
</div>
<div>
@if (catalogPage?.ProductList != null)
{
<div>@catalogPage.ProductList.Count @Translate("products")</div>
if (catalogPage.Type == PublicationPageType.VariantList || catalogPage.Type == PublicationPageType.RelatedList || catalogPage.Type == PublicationPageType.ProductList)
{
if (catalogPage.ProductList != null)
{
foreach (var product in catalogPage.ProductList)
{
<div>
<span>@product.Id @product.VariantId</span>
<span> - @product.Name</span>
<span> - @product.PrimaryOrDefaultGroup.Id</span>
</div>
}
}
}
}
</div>
</div>
}
</div>
}
@* Rendering *@
@foreach (var catalogPage in fullCatalog.Pages)
{
string headerHiddenClass = catalogPage.HideHeader ? " dwp-main-header-hidden" : "";
string footerHiddenClass = catalogPage.HideFooter ? " dwp-main-footer-hidden" : "";
string? pageBackgroundColor = !string.IsNullOrEmpty(catalogPage?.BackgroundColor) ? $"--dwp-page-background:{catalogPage?.BackgroundColor};" : null;
string? pageFontColor = !string.IsNullOrEmpty(catalogPage?.FontColor) ? $"--dwp-page-text-color:{catalogPage?.FontColor};" : null;
string? pageStyle = $"style=\"{pageBackgroundColor}{pageFontColor}\"";
string pageLinkID = catalogPage.PageNumber != 0 ? "page" + catalogPage.PageNumber : null;
string dataPageNumber = catalogPage.PageNumber != 0 ? $"data-page-number=\"{catalogPage.PageNumber}\"" : "";
if (Dynamicweb.Context.Current.Items.Contains("PageNumber"))
{
Dynamicweb.Context.Current.Items["PageNumber"] = catalogPage.PageNumber;
}
else
{
Dynamicweb.Context.Current.Items.Add("PageNumber", catalogPage.PageNumber);
}
if (Dynamicweb.Context.Current.Items.Contains("PageTitle"))
{
Dynamicweb.Context.Current.Items["PageTitle"] = catalogPage.Title;
}
else
{
Dynamicweb.Context.Current.Items.Add("PageTitle", catalogPage.Title);
}
if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
{
Dynamicweb.Context.Current.Items["ProductDetails"] = catalogPage.Product;
}
else
{
Dynamicweb.Context.Current.Items.Add("ProductDetails", catalogPage.Product);
}
if (catalogPage.ProductList != null)
{
if (Dynamicweb.Context.Current.Items.Contains("ProductListForPage"))
{
Dynamicweb.Context.Current.Items["ProductListForPage"] = catalogPage.ProductList;
}
else
{
Dynamicweb.Context.Current.Items.Add("ProductListForPage", catalogPage.ProductList);
}
}
<div class="dwp-page js-dwp-page" @(pageStyle) data-page-type="@catalogPage.Type.ToString().ToLower()" id="@pageLinkID" @dataPageNumber>
@* Tools *@
@if (Pageview.IsVisualEditorMode)
{
string pageEditLink = $"/Default.aspx?ID={catalogPage.PageID}&visualedit=true";
<div>
<div class="dwp-editor-notifications">
@if (catalogPage.Type == PublicationPageType.DataSheet || catalogPage.Type == PublicationPageType.ProductList || catalogPage.Type == PublicationPageType.RelatedList || catalogPage.Type == PublicationPageType.VariantList)
{
<div class="dwp-alert dwp-alert-sm dwp-alert-warning" title="@Translate("This page is based on dynamic product data")">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-triangle"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
</div>
}
@if (catalogPage.Type == PublicationPageType.TableOfContent)
{
<div class="dwp-mini-alert dwp-alert-warning" title="@Translate("TOC pages will not be counted in the page numbers")">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-triangle"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
</div>
}
</div>
<div class="dwp-editor-actions">
<button class="dwp-btn dwp-btn-primary" type="button" onclick="parent.document.querySelector('.view-port').src = '@pageEditLink'">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
</button>
</div>
</div>
}
@* The page *@
@if (headerReference != 0 && !catalogPage.HideHeader)
{
<header class="dwp-header">
@RenderGrid(headerReference)
</header>
}
@{
string overflow = !Pageview.IsVisualEditorMode ? " overflow-hidden" : string.Empty;
}
<main class="dwp-main@(headerHiddenClass)@(footerHiddenClass)@(overflow) js-dwp-main">
@RenderGrid(catalogPage.PageID)
</main>
@if (footerReference != 0 && !catalogPage.HideFooter)
{
<footer class="dwp-footer">
@RenderGrid(footerReference)
</footer>
}
</div>
}
@if (fullCatalog.Pages.Count == 0)
{
<div class="dwp-alert dwp-alert-info dwp-p-2 dwp-mb-2 dwp-text-align-center" role="alert">
@Translate("Start building your catalog by adding pages")
</div>
}
@if(triggerPrintDialog) {
<script type="module">
window.addEventListener('load', ()=> {
window.print();
});
</script>
}
<script type="module">
var bodyStyle = document?.querySelector('.dwp-body')?.style;
var header = document.querySelector('header.dwp-header');
var footer = document.querySelector('footer.dwp-footer');
if (header){
bodyStyle.setProperty('--dwp-page-header-height', `${header?.clientHeight}px`);
}
if (footer){
bodyStyle.setProperty('--dwp-page-footer-height', `${footer?.clientHeight}px`);
}
</script>
</body>
</html>