Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut tellus elementum sagittis vitae et leo.
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut tellus elementum sagittis vitae et leo. Nascetur ridiculus mus mauris vitae ultricies leo integer. Eros donec ac odio tempor orci dapibus ultrices. At in tellus integer feugiat scelerisque.
Tortor aliquam nulla facilisi cras fermentum odio eu. Sagittis orci a scelerisque purus semper eget duis at. Lectus quam id leo in vitae turpis massa. Imperdiet sed euismod nisi porta lorem mollis. Eu turpis egestas pretium aenean pharetra magna ac placerat vestibulum. Vivamus arcu felis bibendum ut tristique et. Amet commodo nulla facilisi nullam. Varius quam quisque id diam vel quam. Sapien faucibus et molestie ac feugiat.
Lorem ipsum
Species
Lorem ipsum
Lorem ipsumError executing template "Designs/Swift/Paragraph/Swift_ArticleList_Custom.cshtml" System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Content.Items.Queries.Repository.IsPageAllowed(Page page) at Dynamicweb.Content.Items.Queries.Repository.GetPagesByIds(IEnumerable`1 parentIds, Boolean includeChildItems, Boolean checkPermissions, List`1& childPages) at Dynamicweb.Content.Items.Queries.Repository.SelectByParentPageIds(IEnumerable`1 parentIds, Query query, Boolean includeParagraphs, Boolean includeChildItems, Boolean checkPermissions, Boolean includeInheritedItems) at Dynamicweb.ItemPublisher.Frontend.GetItems() at Dynamicweb.ItemPublisher.Frontend.List() at Dynamicweb.ItemPublisher.Frontend.GetContent() at Dynamicweb.ItemPublisher.Frontend.GetContentBySettings(String settings) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Dynamicweb.Extensibility.AddIns.AddInManager.InvokeFunction(Object instance, String functionName, Object[] arguments) at Dynamicweb.Rendering.TemplateBase`1.RenderItemList(Object settings) at CompiledRazorTemplates.Dynamic.RazorEngine_15f04249e1224cf78757312d84c08dc8.<>c__DisplayClass3_0.<RenderArticleList>b__0(TextWriter __razor_helper_writer) in F:\Dynamicweb\Solutions\Production\files\Templates\Designs\Swift\Paragraph\Swift_ArticleList_Custom.cshtml:line 284 at CompiledRazorTemplates.Dynamic.RazorEngine_15f04249e1224cf78757312d84c08dc8.Execute() in F:\Dynamicweb\Solutions\Production\files\Templates\Designs\Swift\Paragraph\Swift_ArticleList_Custom.cshtml:line 191 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.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Environment.Helpers 4 @using System 5 6 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 7 8 @helper RenderArticleHeadline() 9 { 10 string layout = Model.Item.GetItem("Headline").GetRawValueString("Layout", "text-left"); 11 string contentPadding = Model.Item.GetItem("Headline").GetRawValueString("ContentPadding", ""); 12 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 13 contentPadding = contentPadding == "small" ? "p-2 p-md-3" : contentPadding; 14 contentPadding = contentPadding == "large" ? "p-4 p-md-5" : contentPadding; 15 string maxWidth = Model.Item.GetItem("Headline").GetRawValueString("TextReadability", ""); 16 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetItem("Headline").GetRawValueString("Theme")) ? " theme " + Model.Item.GetItem("Headline").GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 17 18 19 <div class="@(contentPadding)@(theme) item_@Model.Item.SystemName.ToLower()"> 20 @switch (layout) 21 { 22 case "text-start": 23 @RenderLead(maxWidth) 24 @RenderTitle(maxWidth) 25 break; 26 case "text-center": 27 <div class="d-flex flex-column align-items-center h-100 text-center"> 28 @RenderLead(maxWidth) 29 @RenderTitle(maxWidth) 30 </div> 31 break; 32 case "text-end": 33 <div class="d-flex flex-column align-items-end h-100 text-end"> 34 @RenderLead(maxWidth) 35 @RenderTitle(maxWidth) 36 </div> 37 break; 38 case "alignLeftMiddle": 39 <div class="d-flex flex-column justify-content-center h-100"> 40 @RenderLead(maxWidth) 41 @RenderTitle(maxWidth) 42 </div> 43 break; 44 case "alignCenterMiddle": 45 <div class="d-flex flex-column align-items-center justify-content-center h-100 text-center"> 46 @RenderLead(maxWidth) 47 @RenderTitle(maxWidth) 48 </div> 49 break; 50 } 51 </div> 52 53 } 54 55 @helper RenderLead(string maxWidth) 56 { 57 58 if (!string.IsNullOrEmpty(Model.Item.GetItem("Headline").GetString("Text"))) 59 { 60 string subtitleFontSize = Model.Item.GetItem("Headline").GetRawValueString("SubtitleFontSize", "fs-5"); 61 62 <p class="@subtitleFontSize lead d-block mb-2"> 63 @if (maxWidth == "max-width-on") 64 { 65 <span class="mw-75ch d-inline-block">@Model.Item.GetItem("Headline").GetString("Text")</span> 66 } 67 else 68 { 69 <span>@Model.Item.GetItem("Headline").GetString("Text")</span> 70 } 71 </p> 72 } 73 } 74 75 @helper RenderTitle(string maxWidth) 76 { 77 78 if (!string.IsNullOrEmpty(Model.Item.GetString("Title"))) 79 { 80 string maxWidth = Model.Item.GetItem("Headline").GetRawValueString("TextReadability", "max-width-on"); 81 maxWidth = maxWidth == "max-width-on" ? "mw-75ch d-inline-block" : maxWidth; 82 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth; 83 84 string titleFontSize = Model.Item.GetItem("Headline").GetRawValueString("TitleFontSize", "display-4"); 85 string headingLevel = Model.Item.GetItem("Headline").GetString("HeadingLevel", "h2"); 86 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {maxWidth} mb-3\">"; 87 string headingLevelStop = $"</{headingLevel}>"; 88 89 @headingLevelStart 90 @Model.Item.GetString("Title") 91 @headingLevelStop 92 } 93 } 94 95 96 @{ 97 98 string listSource = !string.IsNullOrEmpty(Model.Item.GetString("ListSource")) ? Model.Item.GetString("ListSource") : Model.PageID.ToString(); 99 string articleListSortOrder = !string.IsNullOrEmpty(Model.Item.GetString("ArticleListSortOrder")) ? Model.Item.GetString("ArticleListSortOrder") : "Descending"; 100 int maxItemsInList = !string.IsNullOrEmpty(Model.Item.GetInt32("MaxItemsInList").ToString()) ? Model.Item.GetInt32("MaxItemsInList") : 10; 101 string articleListLayout = !string.IsNullOrEmpty(Model.Item.GetString("ArticleListLayout")) ? Model.Item.GetString("ArticleListLayout") : "grid"; 102 string columnTheme = !string.IsNullOrEmpty(Model.Item.GetString("ColumnTheme")) ? Model.Item.GetString("ColumnTheme") : string.Empty; 103 string columnThemeClass = columnTheme != string.Empty ? " theme " + columnTheme + " p-3" + (articleListLayout == "carousel" ? " px-lg-4" : string.Empty) : string.Empty; 104 int gridSettings = !string.IsNullOrEmpty(Model.Item.GetInt32("GridSettings").ToString()) ? Model.Item.GetInt32("GridSettings") : 4; 105 int carouselSettings = !string.IsNullOrEmpty(Model.Item.GetInt32("CarouselSettings").ToString()) ? Model.Item.GetInt32("CarouselSettings") : 4; 106 bool hideScrollbar = Model.Item.GetBoolean("HideScrollbar"); 107 string scrollbarClass = hideScrollbar == false ? " slider-nav-scrollbar" : string.Empty; 108 string settingsClassGrid = string.Empty; 109 string settingsClassCarousel = string.Empty; 110 string pageSize = Dynamicweb.Context.Current.Request.QueryString.Get("pageSize"); 111 maxItemsInList = string.IsNullOrEmpty(pageSize) ? maxItemsInList : Convert.ToInt32(pageSize); 112 bool productPageLayout = Model.Item.GetBoolean("ActivateProductPageLayout"); 113 114 115 switch (gridSettings) 116 { 117 case 2: 118 settingsClassGrid = " grid-md-2"; 119 break; 120 case 3: 121 settingsClassGrid = " grid-md-3"; 122 break; 123 case 4: 124 settingsClassGrid = " grid-md-2 grid-lg-3 grid-xl-4"; 125 break; 126 case 5: 127 settingsClassGrid = " grid-md-2 grid-lg-3 grid-xl-5"; 128 break; 129 } 130 switch (carouselSettings) 131 { 132 case 2: 133 settingsClassCarousel = " slider-item-show2"; 134 break; 135 case 3: 136 settingsClassCarousel = " slider-item-show3"; 137 break; 138 case 4: 139 settingsClassCarousel = " slider-item-show4"; 140 break; 141 case 5: 142 settingsClassCarousel = " slider-item-show5"; 143 break; 144 } 145 146 147 string joinedItemEntries = GetItemEntriesCustom(Model.Item); 148 System.Collections.Generic.IEnumerable<Dynamicweb.Content.Page> pages = Dynamicweb.Services.Pages.GetPagesByParentID(Convert.ToInt32(listSource)); 149 150 if (Model.Item.GetBoolean("IncludeArticlesFromAllSubpages")) 151 { 152 List<string> pageIds = GetPages(pages); 153 pageIds.Add(listSource); 154 joinedItemEntries = string.Join(",", pageIds); 155 pages = Dynamicweb.Services.Pages.GetPagesByAreaID(Pageview.AreaID).Where(i => joinedItemEntries.Contains(Convert.ToString(i.ParentPageId))); 156 } 157 158 if (Model.Item.GetBoolean("GetArticlesFromTag")) 159 { 160 pages = Dynamicweb.Services.Pages.GetPagesByAreaID(Pageview.AreaID).Where(page => page.ItemType == "Swift_Article_Custom" && Convert.ToString(page.Item["Tags"]).Contains(Model.Item.GetString("Tag"))); 161 List<string> pageIds = new List<string>(); 162 foreach (var page in pages) 163 { 164 pageIds.Add(Convert.ToString(page.ItemId)); 165 } 166 joinedItemEntries = string.Join(",", pageIds); 167 } 168 169 var subPagesCount = pages != null ? pages.Where(page => page.Published).Count() : 0; 170 171 172 if (!productPageLayout || (productPageLayout && !string.IsNullOrWhiteSpace(joinedItemEntries))) 173 { 174 <div class="@(productPageLayout ? "grid gap-1" : "") "> 175 <div class="@(productPageLayout ? "g-col-12 g-col-lg-4 aos-init aos-animate" : "")"> 176 @if ((Model.Item.GetBoolean("ShowTitleAsHeadline") && !string.IsNullOrEmpty(joinedItemEntries)) || (Model.Item.GetBoolean("ShowTitleAsHeadline") && !Model.Item.GetBoolean("ChooseSpecificArticles") && !Model.Item.GetBoolean("ProductPageArticles"))) 177 { 178 @RenderArticleHeadline() 179 } 180 </div> 181 <div class="@(productPageLayout ? "g-col-12 g-col-lg-8 aos-init aos-animate" : "custom-list-articles") js-list-wrap_@(Model.ItemId)" data-gridsettings="@gridSettings" data-startPageCount="@maxItemsInList" data-totalPageCount="@subPagesCount"> 182 183 @RenderFilterBarCustom(pages, Model.Item.GetBoolean("ShowFilterBar")) 184 185 186 @switch (articleListLayout) 187 { 188 case "grid": 189 <div class="grid gap-1 grid-1@(settingsClassGrid)@(columnThemeClass) item_@Model.Item.SystemName.ToLower()_@Model.ItemId"> 190 191 @RenderArticleList("Swift_Article_Custom", listSource, maxItemsInList, articleListSortOrder, joinedItemEntries) 192 @*@RenderArticleList("Swift_ArticleListPage", listSource, maxItemsInList, articleListSortOrder, joinedItemEntries)*@ 193 </div> 194 if (Model.Item.GetBoolean("ShowLoadMoreButton")) 195 { 196 <div class="text-center custom-load-more-btn-articles"> 197 @if (maxItemsInList < subPagesCount) 198 { 199 <button class="btn btn-secondary js-loadmore" data-itemid="@Model.ItemId" onclick="updateList(this, @Model.ItemId)">@Translate("Vis flere artikler")</button> 200 } 201 </div> 202 } 203 break; 204 205 case "carousel": 206 <div class="swiffy-slider slider-item-reveal slider-nav-round slider-item-nosnap swiffy-gap-lg-4@(settingsClassCarousel)@(columnThemeClass) item_@Model.Item.SystemName.ToLower()"> 207 <div class="slider-container pb-3 py-lg-3 mt-lg-n3@(scrollbarClass)"> 208 @RenderArticleList("Swift_Article_Custom", listSource, maxItemsInList, articleListSortOrder, joinedItemEntries) 209 </div> 210 211 <button type="button" title="@Translate("Slider navigation button - Previous slider")" class="slider-nav"></button> 212 <button type="button" title="@Translate("Slider navigation button - Next slider")" class="slider-nav slider-nav-next"></button> 213 214 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 215 <script type="module"> 216 swift.AssetLoader.Load('Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 217 document.addEventListener('load.swift.assetloader', function () { 218 swiffyslider.init() 219 }); 220 </script> 221 </div> 222 break; 223 } 224 </div> 225 </div> 226 } 227 } 228 229 230 @helper RenderArticleList(string itemType, string listSource, int maxItemsInList, string articleListSortOrder, string joinedItemEntries) 231 { 232 233 if (Model.Item.GetBoolean("ChooseSpecificArticles")) 234 { 235 @RenderItemList(new 236 { 237 ItemType = itemType, 238 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 239 ItemFieldsList = "*", 240 ListSourceType = "ItemEntries", 241 SourceItemEntries = joinedItemEntries, 242 ListPageSize = maxItemsInList, 243 ListOrderBy = "Id", 244 }) 245 } 246 else if (Model.Item.GetBoolean("ProductPageArticles")) 247 { 248 @RenderItemList(new 249 { 250 ItemType = itemType, 251 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 252 ItemFieldsList = "*", 253 ListSourceType = "ItemEntries", 254 SourceItemEntries = joinedItemEntries, 255 ListPageSize = maxItemsInList, 256 IncludeParagraphItems = true, 257 ListOrderBy = "PublishedDate", 258 ListSecondOrderBy = "Updated", 259 ListOrderByDirection = articleListSortOrder 260 }) 261 } 262 else if (Model.Item.GetBoolean("GetArticlesFromTag")) 263 { 264 @RenderItemList(new 265 { 266 ItemType = itemType, 267 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 268 ItemFieldsList = "*", 269 ListSourceType = "ItemEntries", 270 SourceItemEntries = joinedItemEntries, 271 ListPageSize = maxItemsInList, 272 IncludeParagraphItems = true, 273 ListOrderBy = "PublishedDate", 274 ListSecondOrderBy = "Updated", 275 ListOrderByDirection = articleListSortOrder 276 }) 277 } 278 else 279 { 280 if (Model.Item.GetBoolean("IncludeArticlesFromAllSubpages")) 281 { 282 listSource = joinedItemEntries; 283 } 284 @RenderItemList(new 285 { 286 ItemType = itemType, 287 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 288 ItemFieldsList = "*", 289 ListSourceType = "Page", 290 ListSourcePage = listSource, 291 ListPageSize = maxItemsInList, 292 IncludeParagraphItems = true, 293 ListOrderBy = "PublishedDate", 294 ListSecondOrderBy = "Updated", 295 ListOrderByDirection = articleListSortOrder, 296 }) 297 } 298 } 299 300 301 @helper RenderFilterBarCustom(IEnumerable<Dynamicweb.Content.Page> pages, bool showFilterBar) 302 { 303 304 if (showFilterBar) 305 { 306 string selectedTags = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("Tags")) ? Dynamicweb.Context.Current.Request.QueryString.Get("Tags") : ""; 307 string selectedPublishedDate = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("PublishedDate")) ? Dynamicweb.Context.Current.Request.QueryString.Get("PublishedDate") : "01-01-0001"; 308 309 Dictionary<string, List<string>> categories = new Dictionary<string, List<string>>(); 310 311 foreach (var page in pages) 312 { 313 if (string.IsNullOrEmpty(selectedPublishedDate) || Convert.ToDateTime(page?.Item?.GetItem("PublishedDate")) > Convert.ToDateTime(selectedPublishedDate)) 314 { 315 var itemTagPageIds = Convert.ToString(page.Item.GetItem("Tags")).Split(','); 316 317 foreach (var itemTagPageId in itemTagPageIds) 318 { 319 if (Dynamicweb.Core.Converter.ToInt32(itemTagPageId) > 0) 320 { 321 var itemPage = Dynamicweb.Services.Pages.GetPage(Dynamicweb.Core.Converter.ToInt32(itemTagPageId)); 322 323 if (itemPage != null && itemPage.Parent.Published && itemPage.Published && itemPage.AreaId == Pageview.AreaID) 324 { 325 326 if (!categories.ContainsKey(itemPage.Parent.MenuText)) 327 { 328 categories.Add(itemPage.Parent.MenuText, new List<string>()); 329 } 330 331 categories[itemPage.Parent.MenuText].Add(Convert.ToString(itemPage.ID)); 332 333 } 334 } 335 } 336 } 337 } 338 339 <div class="filters pt-3 d-md-flex"> 340 341 @foreach (var item in categories) 342 { 343 string queryString = Dynamicweb.Context.Current.Request.QueryString.Get("Tags") != null ? Convert.ToString(Dynamicweb.Context.Current.Request.QueryString.Get("Tags")) : string.Empty; 344 var tags = queryString?.Split(','); 345 bool defaultValueSelected = string.IsNullOrWhiteSpace(queryString) || (!string.IsNullOrWhiteSpace(queryString) && item.Value.Find(x => queryString.Contains(x)) == null); 346 string selectedTag = string.Empty; 347 348 349 <div class="dropdown me-4"> 350 <select class="form-select btn btn-outline-secondary dropdown-toggle w-100 text-start" onchange="updateList(this, @(Model.ItemId), this.value)"> 351 <option disabled selected="@(defaultValueSelected)">@item.Key</option> 352 @foreach (string topicPageId in item.Value.Distinct()) 353 { 354 var path = LinkHelper.ReplaceQueryString("Tags", topicPageId); 355 bool selected = queryString != null && queryString.Contains(topicPageId) ? true : false; 356 selectedTag = selected ? topicPageId : selectedTag; 357 358 var topicName = Dynamicweb.Services.Pages.GetPage(Convert.ToInt32(topicPageId))?.MenuText; 359 360 361 <option value="@topicPageId" selected="@(selected)">@topicName</option> 362 } 363 @if (!string.IsNullOrEmpty(selectedTag)) 364 { 365 <option value="reset_@(selectedTag)" class="fw-bold">@Translate("Reset")</option> 366 } 367 </select> 368 </div> 369 } 370 371 @{ 372 DateTime startingDate = DateTime.Today; 373 374 string lastWeekDate = startingDate.AddDays(-7).ToString("yyyy-MM-dd"); 375 var lastWeek = "PublishedDate=" + lastWeekDate; 376 377 string lastMonthDate = startingDate.AddMonths(-1).ToString("yyyy-MM-dd"); 378 var lastMonth = "PublishedDate=" + lastMonthDate; 379 380 string lastSixMonthDate = startingDate.AddMonths(-6).ToString("yyyy-MM-dd"); 381 var lastSixMonth = "PublishedDate=" + lastSixMonthDate; 382 383 string resetPath = LinkHelper.StripQueryString("PublishedDate"); 384 resetPath = resetPath.Replace("&PublishedDate.op=gt", ""); 385 } 386 387 <div class="dropdown me-4"> 388 <select class="form-select btn btn-outline-secondary dropdown-toggle w-100 text-start" onchange="updateList(this, @(Model.ItemId), this.value)"> 389 <option disabled selected="@(selectedPublishedDate == "01-01-0001")">@Translate("Date range")</option> 390 <option value="@lastWeek" selected="@(selectedPublishedDate == lastWeekDate)">@Translate("Last week")</option> 391 <option value="@lastMonth" selected="@(selectedPublishedDate == lastMonthDate)">@Translate("Last month")</option> 392 <option value="@lastSixMonth" selected="@(selectedPublishedDate == lastSixMonthDate)">@Translate("Last 6 months")</option> 393 <option value="reset_PublishedDate" class="fw-bold">@Translate("Reset")</option> 394 </select> 395 </div> 396 <div class="dropdown me-4 d-flex align-items-center"> 397 @if (!string.IsNullOrEmpty(selectedTags) || selectedPublishedDate != "01-01-0001") 398 { 399 <button type="button" onclick="updateList(this, @(Model.ItemId), 'reset')" class="btn btn-link">@Translate("Reset filters")</button> 400 } 401 </div> 402 </div> 403 } 404 } 405 406 407 @functions{ 408 string GetItemEntriesCustom(Dynamicweb.Frontend.ItemViewModel articleList) 409 { 410 var pageService = new Dynamicweb.Content.PageService(); 411 List<string> itemEntries = new List<string> { }; 412 if (articleList.GetBoolean("ChooseSpecificArticles") || articleList.GetBoolean("ProductPageArticles")) 413 { 414 if (articleList.GetBoolean("ChooseSpecificArticles")) 415 { 416 foreach (var item in articleList.GetItems("SpecificArticlesToShow")) 417 { 418 Dynamicweb.Frontend.ItemViewModel article = (Dynamicweb.Frontend.ItemViewModel)item?.Fields[0]?.Value; 419 if (article != null && article.SystemName == "Swift_Article_Custom") 420 { 421 itemEntries.Add(article.Id); 422 } 423 } 424 } 425 426 if (articleList.GetBoolean("ChooseSpecificArticles")) 427 { 428 foreach (var item in articleList.GetItems("SpecificArticlesToShow")) 429 { 430 Dynamicweb.Frontend.ItemViewModel article = (Dynamicweb.Frontend.ItemViewModel)item?.Fields[0]?.Value; 431 if (article != null && article.SystemName == "Swift_Article_Custom") 432 { 433 itemEntries.Add(article.Id); 434 } 435 } 436 } 437 438 if (articleList.GetBoolean("ProductPageArticles")) 439 { 440 ProductViewModel product = null; 441 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 442 { 443 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 444 } 445 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 446 { 447 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 448 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 449 450 if (productList?.Products is object) 451 { 452 product = productList.Products[0]; 453 } 454 } 455 if (product is object) 456 { 457 var relatedArticles = product.AssetCategories?.FirstOrDefault(asset => asset.SystemName == "Related_articles"); 458 459 if (relatedArticles != null) 460 { 461 foreach (var asset in relatedArticles.Assets) 462 { 463 string pageLink = Convert.ToString(asset.Value).ToLower(); 464 int pageId = Dynamicweb.Environment.Helpers.LinkHelper.GetInternalPageId(pageLink); 465 var page = pageService.GetPage(pageId); 466 467 if (page != null && page.ItemType == "Swift_Article_Custom") 468 { 469 string itemId = page.ItemId; 470 itemEntries.Add(itemId); 471 } 472 } 473 } 474 } 475 } 476 } 477 478 return string.Join(",", itemEntries); 479 } 480 } 481 @functions{ 482 483 private static List<string> GetPages(System.Collections.Generic.IEnumerable<Dynamicweb.Content.Page> pages) 484 { 485 List<string> pageIds = new List<string> { }; 486 string pageIdsString = string.Empty; 487 if (pages != null) 488 { 489 foreach (Dynamicweb.Content.Page page in pages) 490 { 491 if (page.ItemType == "Swift_ArticleListPage") 492 { 493 pageIds.Add(Convert.ToString(page.ID)); 494 List<string> list = GetPages(Dynamicweb.Services.Pages.GetPagesByParentID(page.ID)); 495 496 foreach (var listPage in list) 497 { 498 pageIds.Add(listPage); 499 } 500 } 501 } 502 } 503 504 505 return pageIds; 506 } 507 }
Lorem ipsum
Lorem ipsum Download
Lorem ipsum Download
Lorem ipsum Download
Lorem ipsumDownload
Lorem ipsumDownload
Lorem ipsumDownload
Error executing template "Designs/Swift/Paragraph/Swift_Custom_GlobalElement.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Content.Layouts.LayoutTemplateLocator.FindLayoutTemplateForPage(Page page) at Dynamicweb.Frontend.Content.GetLayoutForDevice(Page page, DeviceType device) at Dynamicweb.Frontend.Content.CreateGridContent(Int32 contentId, Boolean ignoreVisualEdit) at Dynamicweb.Frontend.Content.RenderExternalGrid(Int32 pageId, String container) at CompiledRazorTemplates.Dynamic.RazorEngine_31f1f8d5236f4d3fa24348e94a9c939c.Execute() in F:\Dynamicweb\Solutions\Production\files\Templates\Designs\Swift\Paragraph\Swift_Custom_GlobalElement.cshtml:line 9 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.ParagraphViewModel> 2 @using Dynamicweb 3 4 5 @{ 6 var pageId = Model.Item.GetInt32("PageId"); 7 } 8 9 @RenderGrid(pageId) 10 11 12