Help & Guidance
Lawn Care
How To Choose The Right Lawn Seed
How To Sow A New Lawn
How To Repair A Patch
How To Overseed An Existing Lawn
How To Mow Your Lawn
How To Water Your Lawn
How To Apply Lawn Feed
How To Remove Weeds & Moss
Lawn Seed Calculator
Grass Identification Guide
Common Lawn Issues
Weeds
Dog Urine Patches
Drought & Soil Condition
Leatherjackets & Chafer Grubs
Ants
Birds
Fungal Diseases
Shade
Moss
Results in just 2 weeks
See the difference for yourself - from tired, patchy grass to a green, vibrant lawn that’s built to last. Our grass seed mixtures are specially developed to germinate quickly, establish strong roots and deliver year-round colour.
Error 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_a194e9970fb24b959f5a89d2f97a27f6.<>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 285 at CompiledRazorTemplates.Dynamic.RazorEngine_a194e9970fb24b959f5a89d2f97a27f6.Execute() in F:\Dynamicweb\Solutions\Production\Files\Templates\Designs\Swift\Paragraph\Swift_ArticleList_Custom.cshtml:line 209 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 <a class="d-none" href="Default.aspx?ID=@Pageview.Page.ID&pagesize=@subPagesCount"></a> 200 <button class="btn btn-secondary js-loadmore" data-itemid="@Model.ItemId" onclick="updateList(this, @Model.ItemId)">@Translate("Vis flere artikler")</button> 201 } 202 </div> 203 } 204 break; 205 206 case "carousel": 207 <div class="swiffy-slider slider-item-reveal slider-nav-round slider-item-nosnap swiffy-gap-lg-4@(settingsClassCarousel)@(columnThemeClass) item_@Model.Item.SystemName.ToLower()"> 208 <div class="slider-container pb-3 py-lg-3 mt-lg-n3@(scrollbarClass)"> 209 @RenderArticleList("Swift_Article_Custom", listSource, maxItemsInList, articleListSortOrder, joinedItemEntries) 210 </div> 211 212 <button type="button" title="@Translate("Slider navigation button - Previous slider")" class="slider-nav"></button> 213 <button type="button" title="@Translate("Slider navigation button - Next slider")" class="slider-nav slider-nav-next"></button> 214 215 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 216 <script type="module"> 217 swift.AssetLoader.Load('Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 218 document.addEventListener('load.swift.assetloader', function () { 219 swiffyslider.init() 220 }); 221 </script> 222 </div> 223 break; 224 } 225 </div> 226 </div> 227 } 228 } 229 230 231 @helper RenderArticleList(string itemType, string listSource, int maxItemsInList, string articleListSortOrder, string joinedItemEntries) 232 { 233 234 if (Model.Item.GetBoolean("ChooseSpecificArticles")) 235 { 236 @RenderItemList(new 237 { 238 ItemType = itemType, 239 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 240 ItemFieldsList = "*", 241 ListSourceType = "ItemEntries", 242 SourceItemEntries = joinedItemEntries, 243 ListPageSize = maxItemsInList, 244 ListOrderBy = "Id", 245 }) 246 } 247 else if (Model.Item.GetBoolean("ProductPageArticles")) 248 { 249 @RenderItemList(new 250 { 251 ItemType = itemType, 252 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 253 ItemFieldsList = "*", 254 ListSourceType = "ItemEntries", 255 SourceItemEntries = joinedItemEntries, 256 ListPageSize = maxItemsInList, 257 IncludeParagraphItems = true, 258 ListOrderBy = "PublishedDate", 259 ListSecondOrderBy = "Updated", 260 ListOrderByDirection = articleListSortOrder 261 }) 262 } 263 else if (Model.Item.GetBoolean("GetArticlesFromTag")) 264 { 265 @RenderItemList(new 266 { 267 ItemType = itemType, 268 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 269 ItemFieldsList = "*", 270 ListSourceType = "ItemEntries", 271 SourceItemEntries = joinedItemEntries, 272 ListPageSize = maxItemsInList, 273 IncludeParagraphItems = true, 274 ListOrderBy = "PublishedDate", 275 ListSecondOrderBy = "Updated", 276 ListOrderByDirection = articleListSortOrder 277 }) 278 } 279 else 280 { 281 if (Model.Item.GetBoolean("IncludeArticlesFromAllSubpages")) 282 { 283 listSource = joinedItemEntries; 284 } 285 @RenderItemList(new 286 { 287 ItemType = itemType, 288 ListTemplate = "ItemPublisher/List/List_Custom.cshtml", 289 ItemFieldsList = "*", 290 ListSourceType = "Page", 291 ListSourcePage = listSource, 292 ListPageSize = maxItemsInList, 293 IncludeParagraphItems = true, 294 ListOrderBy = "PublishedDate", 295 ListSecondOrderBy = "Updated", 296 ListOrderByDirection = articleListSortOrder, 297 }) 298 } 299 } 300 301 302 @helper RenderFilterBarCustom(IEnumerable<Dynamicweb.Content.Page> pages, bool showFilterBar) 303 { 304 305 if (showFilterBar) 306 { 307 string selectedTags = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("Tags")) ? Dynamicweb.Context.Current.Request.QueryString.Get("Tags") : ""; 308 string selectedPublishedDate = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("PublishedDate")) ? Dynamicweb.Context.Current.Request.QueryString.Get("PublishedDate") : "01-01-0001"; 309 310 Dictionary<string, List<string>> categories = new Dictionary<string, List<string>>(); 311 312 foreach (var page in pages) 313 { 314 if (string.IsNullOrEmpty(selectedPublishedDate) || Convert.ToDateTime(page?.Item?.GetItem("PublishedDate")) > Convert.ToDateTime(selectedPublishedDate)) 315 { 316 var itemTagPageIds = Convert.ToString(page.Item.GetItem("Tags")).Split(','); 317 318 foreach (var itemTagPageId in itemTagPageIds) 319 { 320 if (Dynamicweb.Core.Converter.ToInt32(itemTagPageId) > 0) 321 { 322 var itemPage = Dynamicweb.Services.Pages.GetPage(Dynamicweb.Core.Converter.ToInt32(itemTagPageId)); 323 324 if (itemPage != null && itemPage.Parent.Published && itemPage.Published && itemPage.AreaId == Pageview.AreaID) 325 { 326 327 if (!categories.ContainsKey(itemPage.Parent.MenuText)) 328 { 329 categories.Add(itemPage.Parent.MenuText, new List<string>()); 330 } 331 332 categories[itemPage.Parent.MenuText].Add(Convert.ToString(itemPage.ID)); 333 334 } 335 } 336 } 337 } 338 } 339 340 <div class="filters pt-3 d-md-flex"> 341 342 @foreach (var item in categories) 343 { 344 string queryString = Dynamicweb.Context.Current.Request.QueryString.Get("Tags") != null ? Convert.ToString(Dynamicweb.Context.Current.Request.QueryString.Get("Tags")) : string.Empty; 345 var tags = queryString?.Split(','); 346 bool defaultValueSelected = string.IsNullOrWhiteSpace(queryString) || (!string.IsNullOrWhiteSpace(queryString) && item.Value.Find(x => queryString.Contains(x)) == null); 347 string selectedTag = string.Empty; 348 349 350 <div class="dropdown me-4"> 351 <select class="form-select btn btn-outline-secondary dropdown-toggle w-100 text-start" onchange="updateList(this, @(Model.ItemId), this.value)"> 352 <option disabled selected="@(defaultValueSelected)">@item.Key</option> 353 @foreach (string topicPageId in item.Value.Distinct()) 354 { 355 var path = LinkHelper.ReplaceQueryString("Tags", topicPageId); 356 bool selected = queryString != null && queryString.Contains(topicPageId) ? true : false; 357 selectedTag = selected ? topicPageId : selectedTag; 358 359 var topicName = Dynamicweb.Services.Pages.GetPage(Convert.ToInt32(topicPageId))?.MenuText; 360 361 362 <option value="@topicPageId" selected="@(selected)">@topicName</option> 363 } 364 @if (!string.IsNullOrEmpty(selectedTag)) 365 { 366 <option value="reset_@(selectedTag)" class="fw-bold">@Translate("Reset")</option> 367 } 368 </select> 369 </div> 370 } 371 372 @{ 373 DateTime startingDate = DateTime.Today; 374 375 string lastWeekDate = startingDate.AddDays(-7).ToString("yyyy-MM-dd"); 376 var lastWeek = "PublishedDate=" + lastWeekDate; 377 378 string lastMonthDate = startingDate.AddMonths(-1).ToString("yyyy-MM-dd"); 379 var lastMonth = "PublishedDate=" + lastMonthDate; 380 381 string lastSixMonthDate = startingDate.AddMonths(-6).ToString("yyyy-MM-dd"); 382 var lastSixMonth = "PublishedDate=" + lastSixMonthDate; 383 384 string resetPath = LinkHelper.StripQueryString("PublishedDate"); 385 resetPath = resetPath.Replace("&PublishedDate.op=gt", ""); 386 } 387 388 <div class="dropdown me-4"> 389 <select class="form-select btn btn-outline-secondary dropdown-toggle w-100 text-start" onchange="updateList(this, @(Model.ItemId), this.value)"> 390 <option disabled selected="@(selectedPublishedDate == "01-01-0001")">@Translate("Date range")</option> 391 <option value="@lastWeek" selected="@(selectedPublishedDate == lastWeekDate)">@Translate("Last week")</option> 392 <option value="@lastMonth" selected="@(selectedPublishedDate == lastMonthDate)">@Translate("Last month")</option> 393 <option value="@lastSixMonth" selected="@(selectedPublishedDate == lastSixMonthDate)">@Translate("Last 6 months")</option> 394 <option value="reset_PublishedDate" class="fw-bold">@Translate("Reset")</option> 395 </select> 396 </div> 397 <div class="dropdown me-4 d-flex align-items-center"> 398 @if (!string.IsNullOrEmpty(selectedTags) || selectedPublishedDate != "01-01-0001") 399 { 400 <button type="button" onclick="updateList(this, @(Model.ItemId), 'reset')" class="btn btn-link">@Translate("Reset filters")</button> 401 } 402 </div> 403 </div> 404 } 405 } 406 407 408 @functions{ 409 string GetItemEntriesCustom(Dynamicweb.Frontend.ItemViewModel articleList) 410 { 411 var pageService = new Dynamicweb.Content.PageService(); 412 List<string> itemEntries = new List<string> { }; 413 if (articleList.GetBoolean("ChooseSpecificArticles") || articleList.GetBoolean("ProductPageArticles")) 414 { 415 if (articleList.GetBoolean("ChooseSpecificArticles")) 416 { 417 foreach (var item in articleList.GetItems("SpecificArticlesToShow")) 418 { 419 Dynamicweb.Frontend.ItemViewModel article = (Dynamicweb.Frontend.ItemViewModel)item?.Fields[0]?.Value; 420 if (article != null && article.SystemName == "Swift_Article_Custom") 421 { 422 itemEntries.Add(article.Id); 423 } 424 } 425 } 426 427 if (articleList.GetBoolean("ChooseSpecificArticles")) 428 { 429 foreach (var item in articleList.GetItems("SpecificArticlesToShow")) 430 { 431 Dynamicweb.Frontend.ItemViewModel article = (Dynamicweb.Frontend.ItemViewModel)item?.Fields[0]?.Value; 432 if (article != null && article.SystemName == "Swift_Article_Custom") 433 { 434 itemEntries.Add(article.Id); 435 } 436 } 437 } 438 439 if (articleList.GetBoolean("ProductPageArticles")) 440 { 441 ProductViewModel product = null; 442 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 443 { 444 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 445 } 446 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 447 { 448 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 449 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 450 451 if (productList?.Products is object) 452 { 453 product = productList.Products[0]; 454 } 455 } 456 if (product is object) 457 { 458 var relatedArticles = product.AssetCategories?.FirstOrDefault(asset => asset.SystemName == "Related_articles"); 459 460 if (relatedArticles != null) 461 { 462 foreach (var asset in relatedArticles.Assets) 463 { 464 string pageLink = Convert.ToString(asset.Value).ToLower(); 465 int pageId = Dynamicweb.Environment.Helpers.LinkHelper.GetInternalPageId(pageLink); 466 var page = pageService.GetPage(pageId); 467 468 if (page != null && page.ItemType == "Swift_Article_Custom") 469 { 470 string itemId = page.ItemId; 471 itemEntries.Add(itemId); 472 } 473 } 474 } 475 } 476 } 477 } 478 479 return string.Join(",", itemEntries); 480 } 481 } 482 @functions{ 483 484 private static List<string> GetPages(System.Collections.Generic.IEnumerable<Dynamicweb.Content.Page> pages) 485 { 486 List<string> pageIds = new List<string> { }; 487 string pageIdsString = string.Empty; 488 if (pages != null) 489 { 490 foreach (Dynamicweb.Content.Page page in pages) 491 { 492 if (page.ItemType == "Swift_ArticleListPage") 493 { 494 pageIds.Add(Convert.ToString(page.ID)); 495 List<string> list = GetPages(Dynamicweb.Services.Pages.GetPagesByParentID(page.ID)); 496 497 foreach (var listPage in list) 498 { 499 pageIds.Add(listPage); 500 } 501 } 502 } 503 } 504 505 506 return pageIds; 507 } 508 }
Creating Jealous Neighbours
For Over 200 Years