Drucktestgerät
€161,97Auf Lager verfügbar
Error executing template "Designs/Swift/Navigation/MegaMenu.cshtml" System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Dynamicweb.Ecommerce.Products.GroupRelation.GetGroupRelationsByChildId(String childId) at Dynamicweb.Ecommerce.Products.Group.get_IsTopGroup() at Dynamicweb.Ecommerce.Shops.Shop.GetTopLevelGroups(String languageId) 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 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_5ff9a21028264cc8b1c102a53d19a97e.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\hctswift.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Navigation\MegaMenu.cshtml:line 150 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.Ecommerce.Orders 4 @using System.IO 5 @using Dynamicweb.Ecommerce.ProductCatalog 6 @using Dynamicweb.Ecommerce.Common 7 @using System.Text 8 9 @functions { 10 string RenderNavigationItem(Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel node, string pageType, string pageIcon, string iconSize, string layout) 11 { 12 13 var page = Dynamicweb.Content.Services.Pages.GetPage(node.PageId); 14 string totalProductsRender = string.Empty; 15 bool pageTypeSwiftCart = pageType == "Swift_Cart"; 16 if(pageTypeSwiftCart) 17 { 18 string cartId = !string.IsNullOrEmpty(page.Item["ContextCart"].ToString()) ? $"ID=\"Cart_{page.Item["ContextCart"].ToString()}\"" : string.Empty; 19 string jsCartClass = string.IsNullOrEmpty(cartId) ? "js-cart-qty" : string.Empty; 20 double totalProducts = 0; 21 Dynamicweb.Ecommerce.Common.Context.CartContext = null; 22 if (page.Item["ContextCart"] != null) 23 { 24 var orderContext = Dynamicweb.Ecommerce.Services.OrderContexts.GetOrderContextById(page.Item["ContextCart"].ToString()); 25 Dynamicweb.Ecommerce.Common.Context.CartContext = orderContext; 26 } 27 28 if (Dynamicweb.Ecommerce.Common.Context.Cart != null && pageTypeSwiftCart) 29 { 30 bool renderOrderlineCountInsteadOfProductCount = page.Item["RenderOrderlineCountInsteadOfProductCount"] != null ? Convert.ToBoolean(page.Item["RenderOrderlineCountInsteadOfProductCount"]) : false; 31 if (!renderOrderlineCountInsteadOfProductCount) 32 { 33 totalProducts = Dynamicweb.Ecommerce.Common.Context.Cart.GetParentProductLineQuantityCount(Dynamicweb.Ecommerce.Common.Context.Cart.OrderLines); 34 } 35 else 36 { 37 foreach (var orderline in Dynamicweb.Ecommerce.Common.Context.Cart.OrderLines) 38 { 39 if (orderline.HasType(new[] { OrderLineType.Product, OrderLineType.Fixed, OrderLineType.PointProduct, OrderLineType.GiftCard })) 40 { 41 totalProducts++; 42 } 43 } 44 45 totalProducts = Math.Round(totalProducts, 2); 46 } 47 } 48 totalProductsRender = $"<span class=\"{jsCartClass} mini-cart-quantity pe-none\" {cartId} data-order-context=\"{page.Item["ContextCart"]}\">{totalProducts}</span>"; 49 } 50 51 bool iconValid = pageIcon.EndsWith(".svg", StringComparison.OrdinalIgnoreCase) && !pageIcon.EndsWith("none.svg", StringComparison.OrdinalIgnoreCase); 52 string iconPath = iconValid ? Dynamicweb.Context.Current.Server.MapPath(pageIcon) : string.Empty; 53 54 string iconRender = iconValid ? $"<span class=\"{iconSize}\">{ReadFile(iconPath)}</span>" : string.Empty; 55 string nameRender = $"<span class=\"text-wrap-nowrap\">{node.Name}</span>"; 56 57 List<string> navigationItemBuilder = new List<string>(); 58 navigationItemBuilder.Add(layout.ToLower().StartsWith("link") ? nameRender : iconRender); 59 navigationItemBuilder.Add(totalProductsRender); 60 navigationItemBuilder.Add(layout.ToLower().EndsWith("icons") ? iconRender : layout.ToLower().EndsWith("links") ? nameRender : string.Empty); 61 62 return string.Join(" ", navigationItemBuilder); 63 } 64 65 Dictionary<string, object> GetGroupImageParams() 66 { 67 Dictionary<string, object> groupImageParams = new Dictionary<string, object>(); 68 string productGroupImageShape = Model.Parameters["ProductGroupImageShape"] != null ? Model.Parameters["ProductGroupImageShape"].ToString() : string.Empty; 69 string productGroupImageSize = Model.Parameters["ProductGroupImageSize"] != null ? Model.Parameters["ProductGroupImageSize"].ToString() : string.Empty; 70 string ratio = productGroupImageSize.Contains("%") ? Model.Parameters["ProductGroupImageSize"].ToString() : string.Empty; 71 groupImageParams.Add("ProductGroupImageShape", productGroupImageShape); 72 groupImageParams.Add("ProductGroupImageSize", productGroupImageSize); 73 groupImageParams.Add("Ratio", ratio); 74 return groupImageParams; 75 } 76 77 public string GetImagePathSanitized(string imagePath) 78 { 79 if (!imagePath.StartsWith("/Files", StringComparison.OrdinalIgnoreCase)) 80 { 81 if (!imagePath.StartsWith("Files/", StringComparison.OrdinalIgnoreCase)) 82 { 83 imagePath = $"/Files/Images/{imagePath}"; 84 } 85 } 86 return imagePath; 87 } 88 } 89 90 @{ 91 string theme = !string.IsNullOrEmpty(Model.Parameters["theme"].ToString()) ? Model.Parameters["theme"].ToString() : string.Empty; 92 string navAlignment = !string.IsNullOrEmpty(Model.Parameters["NavAlignment"].ToString()) ? Model.Parameters["NavAlignment"].ToString() : string.Empty; 93 string linkFontWeight = !string.IsNullOrEmpty(Model.Parameters["LinkFontWeight"].ToString()) ? Model.Parameters["LinkFontWeight"].ToString() : string.Empty; 94 string linkCasing = !string.IsNullOrEmpty(Model.Parameters["LinkCasing"].ToString()) ? Model.Parameters["LinkCasing"].ToString() : string.Empty; 95 string linkFontSize = !string.IsNullOrEmpty(Model.Parameters["LinkFontSize"].ToString()) ? Model.Parameters["LinkFontSize"].ToString() : string.Empty; 96 string layout = !string.IsNullOrEmpty(Model.Parameters["Layout"].ToString()) ? Model.Parameters["Layout"].ToString() : string.Empty; 97 string iconSize = "icon-3"; 98 99 if (linkFontSize == "fs-7") 100 { 101 iconSize = "icon-2"; 102 } 103 if (linkFontSize == "fs-5") 104 { 105 iconSize = "icon-4"; 106 } 107108 string dropdownAlignment = Model.Parameters["DropdownAlignment"] != null ? Model.Parameters["DropdownAlignment"].ToString() : string.Empty; 109 string dropdownLinkHeaderFontWeight = Model.Parameters["DropdownLinkHeaderFontWeight"] != null ? Model.Parameters["DropdownLinkHeaderFontWeight"].ToString() : string.Empty; 110 string dropdownLinkHeaderCasing = Model.Parameters["DropdownLinkHeaderCasing"] != null ? Model.Parameters["DropdownLinkHeaderCasing"].ToString() : string.Empty; 111 string dropdownLinkHeaderFontSize = Model.Parameters["DropdownLinkHeaderFontSize"] != null ? Model.Parameters["DropdownLinkHeaderFontSize"].ToString() : string.Empty; 112 string dropdownLinkFontWeight = Model.Parameters["DropdownLinkFontWeight"] != null ? Model.Parameters["DropdownLinkFontWeight"].ToString() : string.Empty; 113 string dropdownLinkCasing = Model.Parameters["DropdownLinkCasing"] != null ? Model.Parameters["DropdownLinkCasing"].ToString() : string.Empty; 114 string dropdownLinkFontSize = Model.Parameters["DropdownLinkFontSize"] != null ? Model.Parameters["DropdownLinkFontSize"].ToString() : string.Empty; 115 string productGroupImagePlacement = Model.Parameters["ProductGroupImagePlacement"] != null ? Model.Parameters["ProductGroupImagePlacement"].ToString() : string.Empty; 116 string imageAlignment = ""; 117 string headerLinkAnimation = Model.Parameters["HeaderLinkAnimation"] != null ? Model.Parameters["HeaderLinkAnimation"].ToString() : string.Empty; 118119 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 120 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 121 imageAlignment = dropdownAlignment == "justify-content-start text-start" && productGroupImagePlacement == "flex-column" ? "align-items-start" : imageAlignment; 122 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 123 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 124 imageAlignment = dropdownAlignment == "justify-content-center text-center" && productGroupImagePlacement == "flex-column" ? "align-items-center" : imageAlignment; 125 imageAlignment = dropdownAlignment == "justify-content-end text-end" && productGroupImagePlacement == "flex-row" ? "align-items-center" : imageAlignment; 126 imageAlignment = dropdownAlignment == "justify-content-end text-end" && productGroupImagePlacement == "flex-row-reverse" ? "align-items-center" : imageAlignment; 127 bool showProductGroupPromotionImage = Model.Parameters.ContainsKey("ShowProductGroupPromotionImage") ? Convert.ToBoolean(Model.Parameters["ShowProductGroupPromotionImage"].ToString()) : false; 128 string menuId = Model.Parameters.ContainsKey("menu-id") ? $"menu_{Model.Parameters["menu-id"].ToString().ToLower()}" : string.Empty; 129 int currentParagraphId = Pageview.CurrentParagraph.ID; 130 } 131132 <nav class="d-flex py-0 @navAlignment"> 133 <ul class="nav flex-nowrap @menuId"> 134 @foreach (var node in Model.Nodes) 135 { 136 var page = Dynamicweb.Content.Services.Pages.GetPage(node.PageId); 137 var pageType = !string.IsNullOrEmpty(page.ItemType) ? page.ItemType : "Swift_Page"; 138139 string submenuType = "auto"; 140 if (page.PropertyItem is object && page.PropertyItem.TryGetValue("SubmenuType", out object submenuTypeValue)) 141 { 142 submenuType = Dynamicweb.Core.Converter.ToString(submenuTypeValue); 143 } 144 string pageIcon = string.Empty; 145 if (page.PropertyItem is object && page.PropertyItem.TryGetValue("Icon", out object pageIconValue)) 146 { 147 pageIcon = Dynamicweb.Core.Converter.ToString(pageIconValue); 148 } 149150 var hasChildren = node.Nodes.Count() > 0; 151 string dropdownAttributes = hasChildren ? " role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\" data-bs-toggle=\"dropdown\" data-bs-offset=\"0,0\"" : ""; 152153 bool hasManyChildren = false; 154 foreach (var subnode in node.Nodes) 155 { 156 if (subnode.Nodes.Any()) 157 { 158 hasManyChildren = true; 159 } 160 } 161162 submenuType = submenuType == "auto" && hasManyChildren ? "megamenu" : submenuType; 163 submenuType = submenuType == "auto" && !hasManyChildren ? "dropdown" : submenuType; 164 string submenuTypeCss = submenuType == "dropdown" ? " dropdown" : ""; 165 submenuTypeCss = submenuType == "megamenu" ? " dropdown position-static" : submenuTypeCss; 166167 string nodeId = !string.IsNullOrEmpty(node.GroupId) ? "Megamenu_" + node.GroupId + "_" + currentParagraphId : "Megamenu_Page_" + node.PageId.ToString() + "_" + currentParagraphId; 168 string dataType = !string.IsNullOrEmpty(node.GroupId) ? "group" : "page"; 169170 <li id="@(nodeId)" data-type="@dataType" class="nav-item@(node.IsActive ? " active" : "")@submenuTypeCss"> 171 @if (node.IsClickable) 172 { 173 @:<a class="@headerLinkAnimation nav-link p-2 text-decoration-underline-hover @linkFontWeight @linkCasing @linkFontSize@(node.IsActive ? " active" : "")@(hasChildren ? " dropdown-toggle" : "")" href="@node.Link" @dropdownAttributes id="NavLink_@nodeId"> 174 } 175 else 176 { 177 @:<span class="@headerLinkAnimation nav-link p-2 @linkFontWeight @linkCasing @linkFontSize @dropdownAlignment@(hasChildren ? " dropdown-toggle" : "")" @dropdownAttributes id="NavLink_@nodeId"> 178 } 179180 @RenderNavigationItem(node, pageType, pageIcon, iconSize, layout) 181182 @if (node.IsClickable) 183 { 184 @:</a> 185 } 186 else 187 { 188 @:</span> 189 } 190191 @if (hasChildren) 192 { 193 if (submenuType == "megamenu") 194 { 195 <div class="dropdown-menu megamenu py-4@(theme)" aria-labelledby="@nodeId" id="NavGroup@(nodeId)"> 196 <div class="container-xl overflow-y-auto"> 197 @if (showProductGroupPromotionImage && !string.IsNullOrEmpty(node.GroupId)) 198 { 199 <div class="grid gap-4"> 200 <div class="g-col-9 g-col-xxl-10"> 201 <div class="d-flex flex-wrap gap-3 @dropdownAlignment"> 202 @foreach (var subnode in node.Nodes) 203 { 204 nodeId = !string.IsNullOrEmpty(subnode.GroupId) ? "Megamenu_" + subnode.GroupId + "_" + currentParagraphId : "Megamenu_Page_" + subnode.PageId.ToString() + "_" + currentParagraphId; 205 dataType = !string.IsNullOrEmpty(subnode.GroupId) ? "group" : "page"; 206207 <div class="col-4 col-xl-3 col-xxl-2"> 208 @if (subnode.IsClickable) 209 { 210 @:<a id="@(nodeId)" data-type="@dataType" href="@subnode.Link" class="nav-link px-0 text-decoration-underline-hover lh-sm text-break"> 211 } 212 else 213 { 214 @:<div id="@(nodeId)" data-type="@dataType" class="nav-link px-0 lh-sm text-break"> 215 } 216 @if (productGroupImagePlacement != "none") 217 { 218 Dictionary<string, object> groupImageParams = GetGroupImageParams(); 219220 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 221 @RenderPartial("Navigation/MegaMenu/GroupImage.cshtml", subnode, groupImageParams) 222 <h6 class="m-0 w-100 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 223 </div> 224 } 225 else 226 { 227 <h6 class="m-0 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 228 } 229230 @if (subnode.IsClickable) 231 { 232 @:</a> 233 } 234 else 235 { 236 @:</div> 237 } 238239 @* copy paste group image og lav clickable løsning *@ 240 @if (subnode.Nodes.Any()) 241 { 242 foreach (var subsubnode in subnode.Nodes) 243 { 244 nodeId = !string.IsNullOrEmpty(subsubnode.GroupId) ? "Megamenu_" + subsubnode.GroupId + "_" + currentParagraphId : "Megamenu_Page_" + subsubnode.PageId.ToString() + "_" + currentParagraphId; 245 dataType = !string.IsNullOrEmpty(subsubnode.GroupId) ? "group" : "page"; 246247 if (subsubnode.IsClickable) 248 { 249 <a class="nav-link px-0 text-decoration-underline-hover lh-sm text-break" href="@subsubnode.Link" @(subnode.IsActive ? " aria-current='page'" : "")> 250 @if (productGroupImagePlacement != "none") 251 { 252 Dictionary<string, object> groupImageParams = GetGroupImageParams(); 253254 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 255 @RenderPartial("Navigation/MegaMenu/GroupImage.cshtml", subsubnode, groupImageParams) 256 <span class="w-100 @dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 257 </div> 258 } 259 else 260 { 261 <span class="@dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 262 } 263 </a> 264 } 265 else 266 { 267 <div class="nav-link px-0 text-decoration-underline-hover lh-sm text-break" @(subnode.IsActive ? " aria-current='page'" : "")> 268 @if (productGroupImagePlacement != "none") 269 { 270 Dictionary<string, object> groupImageParams = GetGroupImageParams(); 271 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 272 @RenderPartial("Navigation/MegaMenu/GroupImage.cshtml", subsubnode, groupImageParams) 273 <span class="w-100 @dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 274 </div> 275 } 276 else 277 { 278 <span class="@dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 279 } 280 </div> 281 } 282 } 283 } 284 </div> 285 } 286 </div> 287 </div> 288 <div class="g-col-3 g-col-xxl-2" id="NavGroupPromotion@(nodeId)"> 289 @{ 290 ProductGroupViewModel promotionImageGroup = node.GetProductGroup(); 291 string link = node.Link; 292 IList<FieldValueViewModel> promotionImageGroupFields = promotionImageGroup.GroupFields != null ? promotionImageGroup.GroupFields : null; 293294 if (promotionImageGroupFields != null) 295 { 296 var groupName = promotionImageGroup.Name; 297 string ratio = Model.Parameters["ImageAspectRatio"].ToString(); 298 ratio = ratio != "0" ? ratio : string.Empty; 299 string ratioCssClass = ratio != string.Empty ? " ratio" : ""; 300 string ratioVariable = ratio != "" ? "style=\"--bs-aspect-ratio: " + ratio + "\"" : string.Empty; 301 string productGroupPromotionImage = string.Empty; 302 string productGroupPromotionImageSrc = string.Empty; 303 string productGroupPromotionImagePath = string.Empty; 304 string productGroupPromotionDescription = string.Empty; 305 string productGroupPromotionLinkLabel = string.Empty; 306 string productGroupPromotionLink = string.Empty; 307 string productGroupPromotionImageTheme = Model.Parameters.ContainsKey("ProductGroupPromotionImageTheme") ? Model.Parameters["ProductGroupPromotionImageTheme"].ToString().ToLower() : string.Empty; 308 string gridGap = !string.IsNullOrEmpty(productGroupPromotionImageTheme) ? "gap-0" : "gap-3"; 309 string themePadding = !string.IsNullOrEmpty(productGroupPromotionImageTheme) ? "p-3" : "p-0"; 310311 foreach (FieldValueViewModel field in promotionImageGroupFields) 312 { 313 if (field.SystemName == "ProductGroupPromotionImage") 314 { 315 productGroupPromotionImage = field.Value != null ? field.Value.ToString() : string.Empty; 316 productGroupPromotionImageSrc = Dynamicweb.Context.Current.Server.UrlEncode(GetImagePathSanitized(productGroupPromotionImage)); 317 productGroupPromotionImagePath = $"/Admin/Public/GetImage.ashx?Image={productGroupPromotionImageSrc}&Width=480&Crop=0"; 318 } 319 if (field.SystemName == "ProductGroupPromotionDescription") 320 { 321 productGroupPromotionDescription = field.Value != null ? field.Value.ToString() : string.Empty; 322 } 323 if (field.SystemName == "ProductGroupPromotionLinkLabel") 324 { 325 productGroupPromotionLinkLabel = field.Value != null ? field.Value.ToString() : string.Empty; 326 } 327 if (field.SystemName == "ProductGroupPromotionLink") 328 { 329 productGroupPromotionLink = field.Value != null ? field.Value.ToString() : string.Empty; 330 } 331 } 332333 <div class="grid grid-1 @gridGap@(productGroupPromotionImageTheme)"> 334 @if (productGroupPromotionImage != string.Empty) 335 { 336 productGroupPromotionLink = !string.IsNullOrEmpty(productGroupPromotionLink) ? productGroupPromotionLink : link; 337338 <a href="@productGroupPromotionLink" title="@groupName" id="NavGroupPromotionFigureLink@(promotionImageGroup.Id)"> 339 <figure class="m-0@(ratioCssClass)" @ratioVariable> 340 <img class="img-fluid" src="@productGroupPromotionImagePath" alt="@groupName" style="object-fit:cover" loading="lazy"> 341 </figure> 342 </a> 343 } 344 @if (!string.IsNullOrEmpty(productGroupPromotionDescription) || !string.IsNullOrEmpty(productGroupPromotionLinkLabel)) 345 { 346 <div class="grid grid-1 @themePadding "> 347348 @if (!string.IsNullOrEmpty(productGroupPromotionDescription)) 349 { 350 <h6 class="m-0">@productGroupPromotionDescription</h6> 351 } 352 @if (!string.IsNullOrEmpty(productGroupPromotionLinkLabel)) 353 { 354 productGroupPromotionLink = !string.IsNullOrEmpty(productGroupPromotionLink) ? productGroupPromotionLink : link; 355356 <a href="@productGroupPromotionLink" title="@productGroupPromotionLinkLabel" class="btn btn-link text-start border-0 p-0" id="NavGroupPromotionTextLink@(promotionImageGroup.Id)">@productGroupPromotionLinkLabel</a> 357 } 358 </div> 359 } 360 </div> 361362 } 363 } 364365 </div> 366 </div> 367368 } 369 else 370 { 371372 <div class="d-flex flex-wrap @dropdownAlignment"> 373374 @foreach (var subnode in node.Nodes) 375 { 376 nodeId = !string.IsNullOrEmpty(subnode.GroupId) ? "Megamenu_" + subnode.GroupId + "_" + currentParagraphId : "Megamenu_Page_" + subnode.PageId.ToString() + "_" + currentParagraphId; 377 dataType = !string.IsNullOrEmpty(subnode.GroupId) ? "group" : "page"; 378 page = Dynamicweb.Content.Services.Pages.GetPage(subnode.PageId); 379380381 pageIcon = string.Empty; 382383384385 if (page.PropertyItem is object && page.PropertyItem.TryGetValue("Image", out object subPageIconValue)) 386 { 387 pageIcon = Dynamicweb.Core.Converter.ToString(subPageIconValue); 388 } 389390 <div class="col-4 col-xl-3 col-xxl-2"> 391392 @if (subnode.IsClickable) 393 { 394 @:<a id="@(nodeId)" data-type="@dataType" href="@subnode.Link" class="nav-link px-0 text-decoration-underline-hover lh-sm text-break"> 395 } else { 396 @:<div id="@(nodeId)" data-type="@dataType" class="nav-link px-0 lh-sm text-break"> 397 } 398399 @if (productGroupImagePlacement != "none") 400 { 401 string ratio = Model.Parameters["ImageAspectRatio"].ToString(); 402 ratio = ratio != "0" ? ratio : string.Empty; 403 string ratioCssClass = ratio != string.Empty ? " ratio" : ""; 404 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio + "\"" : string.Empty; 405 string productGroupImageSize = Model.Parameters["ProductGroupImageSize"] != null ? Model.Parameters["ProductGroupImageSize"].ToString() : string.Empty; 406 string productGroupImageShape = Model.Parameters["ProductGroupImageShape"] != null ? Model.Parameters["ProductGroupImageShape"].ToString() : string.Empty; 407 var imageSrc = ""; 408 Dictionary<string, object> groupImageParams = GetGroupImageParams(); 409 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 410 @{@RenderPartial("Navigation/MegaMenu/GroupImage.cshtml", subnode, groupImageParams)} 411 @if (!string.IsNullOrEmpty(pageIcon)){ 412413414 if (pageIcon.Contains(".svg")) 415 { 416 if (!string.IsNullOrEmpty(ratio)) 417 { 418 <div class="submenu_item_image @(ratioCssClass)" style="@ratioVariable"> 419 @ReadFile(pageIcon) 420 </div> 421 } 422 else 423 { 424 <div class="submenu_item_image icon-auto" style="height: @(productGroupImageSize)px; width: @(productGroupImageSize)px;"> 425 @ReadFile(pageIcon) 426 </div> 427 } 428 } else { 429 if (!string.IsNullOrEmpty(ratio)) 430 { 431432 var imagePath = Dynamicweb.Context.Current.Server.UrlEncode(pageIcon); 433 imageSrc = $"/Admin/Public/GetImage.ashx?Image={imagePath}&Width=320"; 434435 <figure class="submenu_item_image @(ratioCssClass) m-0" style="@ratioVariable"> 436 <img loading="lazy" class="@productGroupImageShape" alt="@subnode.Name" src="@imageSrc" style="object-fit: contain"> 437 </figure> 438439 } 440 else 441 { 442 var imagePath = Dynamicweb.Context.Current.Server.UrlEncode(pageIcon); 443 imageSrc = $"/Admin/Public/GetImage.ashx?Image={imagePath}&Width={productGroupImageSize}&Height={productGroupImageSize}&crop=0"; 444445 <img loading="lazy" class="submenu_item_image @productGroupImageShape" alt="@subnode.Name" width="@productGroupImageSize" height="@productGroupImageSize" src="@imageSrc"> 446 } 447448 }} 449 <h6 class="m-0 w-100 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 450 </div> 451 } 452 else 453 { 454 <h6 class="m-0 @dropdownLinkHeaderFontWeight @dropdownLinkHeaderCasing @dropdownLinkHeaderFontSize">@subnode.Name</h6> 455 } 456457 @if (subnode.IsClickable) 458 { 459 @:</a> 460 } 461 else 462 { 463 @:</div> 464 } 465466 @if (subnode.Nodes.Any()) 467 { 468 foreach (var subsubnode in subnode.Nodes) 469 { 470 nodeId = !string.IsNullOrEmpty(subsubnode.GroupId) ? "Megamenu_" + subsubnode.GroupId + "_" + currentParagraphId : "Megamenu_Page_" + subsubnode.PageId.ToString() + "_" + currentParagraphId; 471 dataType = !string.IsNullOrEmpty(subsubnode.GroupId) ? "group" : "page"; 472473 if (subsubnode.IsClickable) { 474 @:<a id="@(nodeId)" data-type="@dataType" class="nav-link px-0 text-decoration-underline-hover lh-sm text-break" href="@subsubnode.Link" @(subnode.IsActive ? " aria-current='page'" : "")> 475 } else { 476 @:<div id="@(nodeId)" data-type="@dataType" class="nav-link px-0 lh-sm text-break" @(subnode.IsActive ? " aria-current='page'" : "")> 477 } 478479 if (productGroupImagePlacement != "none") 480 { 481 Dictionary<string, object> groupImageParams = GetGroupImageParams(); 482 <div class="d-flex @productGroupImagePlacement @imageAlignment gap-3"> 483 @{@RenderPartial("Navigation/MegaMenu/GroupImage.cshtml", subsubnode, groupImageParams)} 484 <span class="w-100 @dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 485 </div> 486 } 487 else 488 { 489 <span class="@dropdownLinkFontWeight @dropdownLinkCasing @dropdownLinkFontSize">@subsubnode.Name</span> 490 } 491 if (subsubnode.IsClickable) 492 { 493 @:</a> 494 } 495 else 496 { 497 @:</div> 498 } 499 } 500 } 501 </div> 502 } 503 </div> 504 } 505 </div> 506 </div> 507 } 508 else 509 { 510 <ul class="dropdown-menu@(theme)" aria-labelledby="@nodeId"> 511 @if (pageType == "Swift_SignIn") 512 { 513 if (Pageview.User == null) 514 { 515 <li> 516 <a href="@node.Link" class="px-3 py-2 dropdown-item text-decoration-underline-hover @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@node.Name</a> 517 </li> 518 } 519 } 520521 @foreach (var subnode in node.Nodes) 522 { 523 <li> 524 @if (subnode.IsClickable) 525 { 526 <a class="px-3 py-2 dropdown-item text-decoration-underline-hover @linkFontWeight @linkCasing @linkFontSize" href="@subnode.Link" @(node.IsActive ? " aria-current='page'" : "")>@subnode.Name</a> 527 } 528 else 529 { 530 <span class="px-3 py-2 dropdown-item @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@subnode.Name</span> 531 } 532 </li> 533 } 534535 @if (pageType == "Swift_SignIn") 536 { 537 if (Pageview.User != null) 538 { 539 string link = "/Admin/Public/ExtranetLogoff.aspx?redirect=no"; 540541 <li><hr class="dropdown-divider"></li> 542543 if (Dynamicweb.Security.UserManagement.User.GetCurrentSecondaryUser() != null) 544 { 545 <li> 546 <a href="Default.aspx?ID=@(Pageview.ID)&DwExtranetRemoveSecondaryUser=1" class="px-3 py-2 dropdown-item text-decoration-underline-hover swift_sign-out-as-customer-link @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@Translate("Sign out as a customer")</a> 547 </li> 548 } 549 <li> 550 <a href="@link" class="px-3 py-2 dropdown-item text-decoration-underline-hover swift_sign-out-link @linkFontWeight @linkCasing @linkFontSize" @(node.IsActive ? " aria-current='page'" : "")>@Translate("Sign out")</a> 551 </li> 552 } 553554 } 555 </ul> 556 } 557 } 558 </li> 559 } 560 </ul> 561 </nav> 562