Väikesed pannkoogid
Kes ei armastaks pliine? Need on nii laste kui täiskasvanute...
Error executing template "Designs/Swift/Navigation/MegaMenu.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Ecommerce.Extensibility.Controls.ProductsAndGroupsHandler.IsHandlerInCache(String handlerData) at Dynamicweb.Ecommerce.Frontend.Navigation.GroupNavigationTreeNodeProvider.GetGroupsBySettings(PageNavigationSettings ecomSettings) at Dynamicweb.Ecommerce.Frontend.Navigation.GroupNavigationTreeNodeProvider.GetGroups(NavigationTreeNode parent, Page page) at Dynamicweb.Ecommerce.Frontend.Navigation.GroupNavigationTreeNodeProvider.GetNodes(NavigationContext context, NavigationSettings settings, NavigationTreeNode parent) at Dynamicweb.Frontend.Navigation.NavigationService.<>c__DisplayClass1_0.<GetNavigationNodes>b__0(NavigationTreeNodeProvider provider) at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source) at CompiledRazorTemplates.Dynamic.RazorEngine_e0b729e2521a4c4d863bc9839bee5875.<>c__DisplayClass0_0.<RenderFirstLevelNodes>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Navigation\MegaMenu.cshtml:line 51 at CompiledRazorTemplates.Dynamic.RazorEngine_e0b729e2521a4c4d863bc9839bee5875.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Navigation\MegaMenu.cshtml:line 16 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.Navigation.NavigationTreeViewModel> 2 @using Dynamicweb 3 @using Dynamicweb.Frontend 4 @using System.IO 5 @using Dynamicweb.Ecommerce.ProductCatalog 6 7 @{ 8 string theme = Model.Parameters["theme"] != null ? Model.Parameters["theme"].ToString() : string.Empty; 9 string navAlignment = Model.Parameters["NavAlignment"] != null ? Model.Parameters["NavAlignment"].ToString() : string.Empty; 10 string linkFontWeight = Model.Parameters["LinkFontWeight"] != null ? Model.Parameters["LinkFontWeight"].ToString() : string.Empty; 11 string linkCasing = Model.Parameters["LinkCasing"] != null ? Model.Parameters["LinkCasing"].ToString() : string.Empty; 12 string linkFontSize = Model.Parameters["LinkFontSize"] != null ? Model.Parameters["LinkFontSize"].ToString() : string.Empty; 13 } 14 15 <nav class="navbar navbar-expand d-none d-lg-flex mx-n2 position-static megamenu-wrapper py-0 @navAlignment"> 16 @RenderFirstLevelNodes(Model.Nodes, theme, linkFontWeight, linkCasing, linkFontSize) 17 </nav> 18 19 <nav class="navbar navbar-expand d-flex d-lg-none mx-n2 py-0 @navAlignment"> 20 @RenderFirstLevelNodesMobile(Model.Nodes, linkFontWeight, linkCasing, linkFontSize, navAlignment) 21 </nav> 22 23 @helper RenderFirstLevelNodes(IEnumerable<Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel> nodes, string theme, string linkFontWeight, string linkCasing, string linkFontSize) 24 { 25 string dropdownAlignment = Model.Parameters["DropdownAlignment"] != null ? Model.Parameters["DropdownAlignment"].ToString() : string.Empty; 26 string dropdownLinkHeaderFontWeight = Model.Parameters["DropdownLinkHeaderFontWeight"] != null ? Model.Parameters["DropdownLinkHeaderFontWeight"].ToString() : string.Empty; 27 string dropdownLinkHeaderCasing = Model.Parameters["DropdownLinkHeaderCasing"] != null ? Model.Parameters["DropdownLinkHeaderCasing"].ToString() : string.Empty; 28 string dropdownLinkHeaderFontSize = Model.Parameters["DropdownLinkHeaderFontSize"] != null ? Model.Parameters["DropdownLinkHeaderFontSize"].ToString() : string.Empty; 29 string dropdownLinkFontWeight = Model.Parameters["DropdownLinkFontWeight"] != null ? Model.Parameters["DropdownLinkFontWeight"].ToString() : string.Empty; 30 string dropdownLinkCasing = Model.Parameters["DropdownLinkCasing"] != null ? Model.Parameters["DropdownLinkCasing"].ToString() : string.Empty; 31 string dropdownLinkFontSize = Model.Parameters["DropdownLinkFontSize"] != null ? Model.Parameters["DropdownLinkFontSize"].ToString() : string.Empty; 32 string productGroupImagePlacement = Model.Parameters["ProductGroupImagePlacement"] != null ? Model.Parameters["ProductGroupImagePlacement"].ToString() : string.Empty; 33 string imageAlignment = ""; 34 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 35 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 36 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-column" ? "align-items-start" : imageAlignment; 37 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 38 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 39 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-column" ? "align-items-center" : imageAlignment; 40 imageAlignment = dropdownAlignment == "justify-content-end text-end" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 41 imageAlignment = dropdownAlignment == "justify-content-end text-end" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 42 bool showProductGroupPromotionImage = Model.Parameters.ContainsKey("ShowProductGroupPromotionImage") ? Convert.ToBoolean(Model.Parameters["ShowProductGroupPromotionImage"].ToString()) : false; 43 44 <ul class="navbar-nav"> 45 @foreach (var node in nodes) 46 { 47 var page = Dynamicweb.Services.Pages.GetPage(node.PageId); 48 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 49 string submenuType = pageViewModel?.PropertyItem != null ? pageViewModel.PropertyItem.GetRawValueString("SubmenuType", "auto") : "auto"; 50 51 var hasChildren = node.Nodes.Count() > 0; 52 string dropdownAttributes = hasChildren ? " role=\"button\" data-bs-toggle=\"\" aria-haspopup=\"true\" aria-expanded=\"false\"" : ""; 53 54 bool hasManyChildren = false; 55 foreach (var subnode in node.Nodes) 56 { 57 if (subnode.Nodes.Any()) 58 { 59 hasManyChildren = true; 60 } 61 } 62 63 submenuType = submenuType == "auto" && hasManyChildren ? "megamenu" : submenuType; 64 submenuType = submenuType == "auto" && !hasManyChildren ? "dropdown" : submenuType; 65 string submenuTypeCss = submenuType == "dropdown" ? " dropdown" : ""; 66 submenuTypeCss = submenuType == "megamenu" ? " dropdown has-megamenu" : submenuTypeCss; 67 68 string nodeId = !string.IsNullOrEmpty(node.GroupId) ? node.GroupId : "Page_" + node.PageId.ToString(); 69 string dataType = !string.IsNullOrEmpty(node.GroupId) ? "group" : "page"; 70 71 <li id="@(nodeId)" data-type="@dataType" class="nav-item@(node.IsActive ? " active" : "")@submenuTypeCss"> 72 @if (node.IsClickable) 73 { 74 <a class="nav-link nav-link-clean nav-link-underline @linkFontWeight @linkCasing @linkFontSize@(node.IsActive ? " active" : "")@(hasChildren ? " " : "")" href="@node.Link" @dropdownAttributes> 75 @RenderNavigationItem(node, pageViewModel) 76 </a> 77 } 78 else 79 { 80 <span class="nav-link nav-link-clean @linkFontWeight @linkCasing @linkFontSize" @dropdownAlignment> 81 @RenderNavigationItem(node, pageViewModel) 82 </span> 83 } 84 85 @if (hasChildren) 86 { 87 if (submenuType == "megamenu") 88 { 89 <div class="dropdown-menu megamenu py-4@(theme) pt-5" id="NavGroup@(node.PageId)"> 90 <div class="container-xl megamenu-container"> 91 @if (showProductGroupPromotionImage && !string.IsNullOrEmpty(node.GroupId)) 92 { 93 <div class="grid gap-4"> 94 <div class="g-col-9 g-col-xxl-10"> 95 <div class="d-flex flex-wrap gap-3 mx-n2 @dropdownAlignment"> 96 @foreach (var subnode in node.Nodes) 97 { 98 nodeId = !string.IsNullOrEmpty(subnode.GroupId) ? subnode.GroupId : "Page_" + subnode.PageId.ToString(); 99 dataType = !string.IsNullOrEmpty(subnode.GroupId) ? "group" : "page"; 100 101 <div class="col-3 col-xl-3 col-xxl-3 megamenu-col"> 102 <a id="@(nodeId)" data-type="@dataType" href="@subnode.Link" class="nav-link nav-link-underline lh-sm text-break"> 103 @if (productGroupImagePlacement != "none") 104 { 105 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 106 @RenderGroupImage(subnode.GetProductGroup()) 107 <h6 class="m-0 w-100 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 108 </div> 109 } 110 else 111 { 112 <h6 class="m-0 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 113 } 114 </a> 115 @if (subnode.Nodes.Any()) 116 { 117 foreach (var subsubnode in subnode.Nodes) 118 { 119 nodeId = !string.IsNullOrEmpty(subsubnode.GroupId) ? subsubnode.GroupId : "Page_" + subsubnode.PageId.ToString(); 120 dataType = !string.IsNullOrEmpty(subsubnode.GroupId) ? "group" : "page"; 121 122 <a class="nav-link nav-link-underline lh-sm text-break" href="@subsubnode.Link" @(subnode.IsActive ? " aria-current='page'" : "")> 123 @if (productGroupImagePlacement != "none") 124 { 125 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 126 @RenderGroupImage(subsubnode.GetProductGroup()) 127 <span class="w-100 @dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 128 </div> 129 } 130 else 131 { 132 <span class="@dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 133 } 134 </a> 135 } 136 } 137 </div> 138 } 139 </div> 140 </div> 141 <div class="g-col-3 g-col-xxl-2"> 142 @RenderProductGroupPromotionImage(node.GetProductGroup(), node.Link) 143 </div> 144 </div> 145 } 146 else 147 { 148 <div class="d-flex flex-wrap mx-n2 @dropdownAlignment"> 149 @foreach (var subnode in node.Nodes) 150 { 151 nodeId = !string.IsNullOrEmpty(subnode.GroupId) ? subnode.GroupId : "Page_" + subnode.PageId.ToString(); 152 dataType = !string.IsNullOrEmpty(subnode.GroupId) ? "group" : "page"; 153 var subpage = Dynamicweb.Services.Pages.GetPage(subnode.PageId); 154 155 <div class="col-4 col-xl-3 col-xxl-3 megamenu-col"> 156 <a id="@(nodeId)" data-type="@dataType" href="@subnode.Link" class="nav-link nav-link-underline lh-sm text-break"> 157 @if(@subpage.ShowInSitemap) 158 { 159 if (productGroupImagePlacement != "none") 160 { 161 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 162 @RenderGroupImage(subnode.GetProductGroup()) 163 <h6 class="m-0 w-100 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 164 </div> 165 } 166 else 167 { 168 <h6 class="m-0 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 169 } 170 } 171 172 </a> 173 @if (subnode.Nodes.Any()) 174 { 175 foreach (var subsubnode in subnode.Nodes) 176 { 177 nodeId = !string.IsNullOrEmpty(subsubnode.GroupId) ? subsubnode.GroupId : "Page_" + subsubnode.PageId.ToString(); 178 dataType = !string.IsNullOrEmpty(subsubnode.GroupId) ? "group" : "page"; 179 180 <a id="@(nodeId)" data-type="@dataType" class="nav-link nav-link-underline lh-sm text-break" href="@subsubnode.Link" @(subnode.IsActive ? " aria-current='page'" : "")> 181 @if (productGroupImagePlacement != "none") 182 { 183 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 184 @RenderGroupImage(subsubnode.GetProductGroup()) 185 <span class="w-100 @dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 186 </div> 187 } 188 else 189 { 190 <span class="@dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 191 } 192 </a> 193 } 194 } 195 </div> 196 } 197 </div> 198 } 199 </div> 200 </div> 201 } 202 else 203 { 204 string pageType = page.ItemType; 205 206 <ul class="dropdown-menu@(theme)"> 207 @if (pageType == "Swift_SignIn") 208 { 209 if (Pageview.User == null) 210 { 211 <li> 212 <a href="@node.Link" class="dropdown-item nav-link-underline @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@node.Name</a> 213 </li> 214 } 215 } 216 217 @foreach (var subnode in node.Nodes) 218 { 219 <li> 220 <a class="dropdown-item nav-link-underline @linkFontWeight @linkCasing @linkFontSize" href="@subnode.Link" @(node.IsActive ? " aria-current='page'" : "")>@subnode.Name</a> 221 </li> 222 } 223 224 @if (pageType == "Swift_SignIn") 225 { 226 if (Pageview.User != null) 227 { 228 string link = "/Admin/Public/ExtranetLogoff.aspx?redirect=no"; 229 230 <li><hr class="dropdown-divider"></li> 231 232 if (Pageview.User.CurrentSecondaryUser != null) 233 { 234 <li> 235 <a href="Default.aspx?ID=@(Pageview.ID)&DwExtranetRemoveSecondaryUser=1" class="dropdown-item nav-link-underline @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@Translate("Sign out as a customer")</a> 236 </li> 237 } 238 <li> 239 <a href="@link" class="dropdown-item nav-link-underline @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@Translate("Sign out")</a> 240 </li> 241 } 242 243 } 244 </ul> 245 } 246 } 247 </li> 248 } 249 </ul> 250 } 251 252 @helper RenderFirstLevelNodesMobile(IEnumerable<Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel> nodes, string linkFontWeight, string linkCasing, string linkFontSize, string navAlignment) 253 { 254 <div class="navbar-nav"> 255 @foreach (var node in nodes) 256 { 257 var page = Dynamicweb.Services.Pages.GetPage(node.PageId); 258 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 259 var hasChildren = node.Nodes.Count() > 0; 260 261 if (node.IsClickable) 262 { 263 <a class="nav-link nav-link-clean text-nowrap @linkFontWeight @linkCasing @linkFontSize @(node.IsActive ? " active" : "")" href="@node.Link"> 264 @RenderNavigationItem(node, pageViewModel) 265 </a> 266 } 267 else 268 { 269 <span class="nav-link nav-link-clean text-nowrap @linkFontWeight @linkCasing @linkFontSize"> 270 @RenderNavigationItem(node, pageViewModel) 271 </span> 272 } 273 } 274 </div> 275 } 276 277 @helper RenderNavigationItem(Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel node, PageInfoViewModel pageViewModel) 278 { 279 string pageType = pageViewModel?.Item?.SystemName != null ? pageViewModel.Item.SystemName : "Swift_Page"; 280 string linkFontSize = Model.Parameters["LinkFontSize"].ToString(); 281 string layout = Model?.Parameters["Layout"].ToString(); 282 string icon = pageViewModel?.PropertyItem != null ? pageViewModel.PropertyItem.GetRawValueString("Icon", "") : ""; 283 string iconSize = "icon-3"; 284 285 if (linkFontSize == "fs-7") 286 { 287 iconSize = "icon-2"; 288 } 289 if (linkFontSize == "fs-5") 290 { 291 iconSize = "icon-4"; 292 } 293 294 if (pageType == "Swift_Cart") 295 { 296 double totalProducts = 0; 297 298 if (Dynamicweb.Ecommerce.Common.Context.Cart != null) 299 { 300 totalProducts = Dynamicweb.Ecommerce.Common.Context.Cart.GetParentProductLineQuantityCount(Dynamicweb.Ecommerce.Common.Context.Cart.OrderLines); 301 } 302 303 switch (layout) 304 { 305 case "linksOnly": 306 <span class="align-middle">@node.Name</span> 307 <span class="js-cart-qty mini-cart-quantity align-middle">(@totalProducts)</span> 308 break; 309 case "iconsOnly": 310 @RenderIcon(icon, iconSize) 311 <span class="js-cart-qty mini-cart-quantity align-middle">(@totalProducts)</span> 312 break; 313 case "iconsAndLinks": 314 @RenderIcon(icon, iconSize) 315 <span class="js-cart-qty mini-cart-quantity align-middle">(@totalProducts)</span> 316 <span class="align-middle">@node.Name</span> 317 break; 318 case "linksAndIcons": 319 <span class="align-middle">@node.Name</span> 320 <span class="js-cart-qty mini-cart-quantity align-middle">(@totalProducts)</span> 321 @RenderIcon(icon, iconSize) 322 break; 323 } 324 } 325 else 326 { 327 switch (layout) 328 { 329 case "linksOnly": 330 <span class="align-middle">@node.Name</span> 331 break; 332 333 case "iconsOnly": 334 @RenderIcon(icon, iconSize) 335 break; 336 case "iconsAndLinks": 337 @RenderIcon(icon, iconSize) 338 <span class="align-middle">@node.Name</span> 339 break; 340 case "linksAndIcons": 341 <span class="align-middle">@node.Name</span> 342 @RenderIcon(icon, iconSize) 343 break; 344 } 345 } 346 } 347 348 @helper RenderIcon(string icon, string iconSize) 349 { 350 if (Path.GetExtension(icon).ToLower() == ".svg" && !icon.ToLower().Contains("none")) 351 { 352 string iconPath = Dynamicweb.Context.Current.Server.MapPath(icon); 353 354 <span class="@iconSize"> 355 @ReadFile(iconPath) 356 </span> 357 } 358 } 359 360 361 @helper RenderProductGroupPromotionImage(ProductGroupViewModel group, string link) 362 { 363 IList<FieldValueViewModel> groupFields = group.GroupFields != null ? group.GroupFields : null; 364 365 if (groupFields != null) 366 { 367 var groupName = group.Name; 368 string ratio = Model.Parameters["ImageAspectRatio"].ToString(); 369 ratio = ratio != "0" ? ratio : string.Empty; 370 string ratioCssClass = ratio != string.Empty ? " ratio" : ""; 371 string ratioVariable = ratio != "" ? "style=\"--bs-aspect-ratio: " + ratio + "\"" : string.Empty; 372 string productGroupPromotionImage = string.Empty; 373 string productGroupPromotionImagePath = string.Empty; 374 string productGroupPromotionDescription = string.Empty; 375 string productGroupPromotionLinkLabel = string.Empty; 376 string productGroupPromotionLink = string.Empty; 377 string productGroupPromotionImageTheme = Model.Parameters.ContainsKey("ProductGroupPromotionImageTheme") ? Model.Parameters["ProductGroupPromotionImageTheme"].ToString().ToLower() : string.Empty; 378 string gridGap = !string.IsNullOrEmpty(productGroupPromotionImageTheme) ? "gap-0" : "gap-3"; 379 string themePadding = !string.IsNullOrEmpty(productGroupPromotionImageTheme) ? "p-3" : "p-0"; 380 381 foreach (FieldValueViewModel field in groupFields) 382 { 383 if (field.SystemName == "ProductGroupPromotionImage") 384 { 385 productGroupPromotionImage = field.Value != null ? field.Value.ToString() : string.Empty; 386 productGroupPromotionImagePath = "/Admin/Public/GetImage.ashx?Width=" + 480 + "&crop=0&image=" + "Files/Images/" + productGroupPromotionImage; 387 } 388 if (field.SystemName == "ProductGroupPromotionDescription") 389 { 390 productGroupPromotionDescription = field.Value != null ? field.Value.ToString() : string.Empty; 391 } 392 if (field.SystemName == "ProductGroupPromotionLinkLabel") 393 { 394 productGroupPromotionLinkLabel = field.Value != null ? field.Value.ToString() : string.Empty; 395 } 396 if (field.SystemName == "ProductGroupPromotionLink") 397 { 398 productGroupPromotionLink = field.Value != null ? field.Value.ToString() : string.Empty; 399 } 400 } 401 402 <div class="grid grid-1 @gridGap@(productGroupPromotionImageTheme)"> 403 @if (productGroupPromotionImage != string.Empty) 404 { 405 productGroupPromotionLink = !string.IsNullOrEmpty(productGroupPromotionLink) ? productGroupPromotionLink : link; 406 407 <a href="@productGroupPromotionLink" title="@groupName"> 408 <figure class="m-0@(ratioCssClass)" @ratioVariable> 409 <img class="img-fluid" src="@productGroupPromotionImagePath" alt="@groupName" style="object-fit:cover"> 410 </figure> 411 </a> 412 } 413 @if (!string.IsNullOrEmpty(productGroupPromotionDescription) || !string.IsNullOrEmpty(productGroupPromotionLinkLabel)) 414 { 415 <div class="grid grid-1 @themePadding "> 416 417 @if (!string.IsNullOrEmpty(productGroupPromotionDescription)) 418 { 419 <h6 class="m-0">@productGroupPromotionDescription</h6> 420 } 421 @if (!string.IsNullOrEmpty(productGroupPromotionLinkLabel)) 422 { 423 productGroupPromotionLink = !string.IsNullOrEmpty(productGroupPromotionLink) ? productGroupPromotionLink : link; 424 425 <a href="@productGroupPromotionLink" title="@productGroupPromotionLinkLabel" class="btn btn-link text-start border-0 p-0">@productGroupPromotionLinkLabel</a> 426 } 427 </div> 428 } 429 </div> 430 } 431 } 432 433 @helper RenderGroupImage(ProductGroupViewModel group) 434 { 435 IList<FieldValueViewModel> groupFields = group.GroupFields; 436 437 if (groupFields != null) 438 { 439 foreach (FieldValueViewModel field in groupFields) 440 { 441 if (field.SystemName == "ProductGroupNavigationImage") 442 { 443 if (!string.IsNullOrEmpty(field.Value.ToString())) 444 { 445 string productGroupImageShape = Model.Parameters["ProductGroupImageShape"] != null ? Model.Parameters["ProductGroupImageShape"].ToString() : string.Empty; 446 string productGroupImageSize = Model.Parameters["ProductGroupImageSize"] != null ? Model.Parameters["ProductGroupImageSize"].ToString() : string.Empty; 447 string ratio = productGroupImageSize.Contains("%") ? Model.Parameters["ProductGroupImageSize"].ToString() : string.Empty; 448 string ratioCssClass = ratio != string.Empty ? "ratio" : string.Empty; 449 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : string.Empty; 450 var groupImage = field.Value.ToString(); 451 var groupName = group.Name; 452 453 if (Path.GetExtension(groupImage).ToLower() == ".svg") 454 { 455 if (!string.IsNullOrEmpty(ratio)) 456 { 457 <div class="@(ratioCssClass)" style="@ratioVariable"> 458 @ReadFile("/Files/Images/" + groupImage) 459 </div> 460 } 461 else 462 { 463 <div class="icon-auto" style="height: @(productGroupImageSize)px; width: @(productGroupImageSize)px;"> 464 @ReadFile("/Files/Images/" + groupImage) 465 </div> 466 } 467 468 } 469 else 470 { 471 if (!string.IsNullOrEmpty(ratio)) 472 { 473 var imagePath = "/Admin/Public/GetImage.ashx?Image=" + "/Files/Images/" + groupImage + "&Width=640&crop=0"; 474 475 <figure class="@(ratioCssClass) m-0" style="@ratioVariable"> 476 <img loading="lazy" class="@productGroupImageShape" alt="@groupName" src="@imagePath" style="object-fit: cover"> 477 </figure> 478 479 } 480 else 481 { 482 var imagePath = "/Admin/Public/GetImage.ashx?Image=" + "/Files/Images/" + groupImage + "&Width=" + productGroupImageSize + "&Height=" + productGroupImageSize + "&crop=0"; 483 484 <img loading="lazy" class="@productGroupImageShape" alt="@groupName" width="@productGroupImageSize" height="@productGroupImageSize" src="@imagePath"> 485 } 486 } 487 } 488 } 489 } 490 } 491 } 492