Unicorn fit banjo

Avanceret cykler
designet til hvad som helst

Få en sjov tur eller god tid på vejen

Hoodie selfies 8-bit, echo park lomo sartorial ugh tonx tilde 3 wolf moon snackwave twee listicle. Semiotics irony chillwave tbh, la croix taxidermy blog.

Error executing template "Designs/Swift/Paragraph/Swift_Slider.cshtml"
System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations)
   at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument()
   at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document)
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Frontend 4 5 @functions { 6 7 private Dynamicweb.Frontend.LinkViewModel GetLink(ItemViewModel item) 8 { 9 string linkType = item.GetRawValueString("LinkType", "page"); 10 11 if (linkType == "page" && item.GetLink("ButtonLink") is LinkViewModel buttonLink) 12 { 13 return buttonLink; 14 } 15 else if (linkType == "product-group") 16 { 17 IList<ProductGroupViewModel> selectedGroups = item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink"); 18 IList<string> groupIds = new List<string> { }; 19 20 if (selectedGroups != null) 21 { 22 foreach (var fromGroup in selectedGroups) 23 { 24 groupIds.Add(fromGroup.Id); 25 } 26 } 27 28 return new Dynamicweb.Frontend.LinkViewModel() 29 { 30 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(), 31 IsExternal = false 32 }; 33 } 34 else if (linkType == "product") 35 { 36 ProductListViewModel products = item.GetValue<ProductListViewModel>("ProductLink"); 37 IList<string> productIds = new List<string> { }; 38 39 if (products != null && products.Products.Any()) 40 { 41 foreach (var product in products.Products) 42 { 43 productIds.Add(product.Id); 44 } 45 string productLink; 46 if (productIds.Count != 1) 47 { 48 productLink = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&MainProductId=" + string.Join(",", productIds).Trim(); 49 } 50 else 51 { 52 productLink = products.Products?.FirstOrDefault()?.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 53 } 54 55 return new Dynamicweb.Frontend.LinkViewModel() 56 { 57 Url = productLink, 58 IsExternal = false 59 }; 60 } 61 } 62 63 return new Dynamicweb.Frontend.LinkViewModel(); 64 } 65 66 private string RenderButton(ItemViewModel item, string buttonSize) 67 { 68 var link = GetLink(item); 69 string stretchedLink = item.GetRawValueString("StretchedLink", string.Empty); 70 stretchedLink = stretchedLink == "not-clickable" ? string.Empty : stretchedLink; 71 stretchedLink = stretchedLink == "clickable" ? "stretched-link" : stretchedLink; 72 73 if (link != null && !string.IsNullOrEmpty(item.GetString("ButtonLabel"))) 74 { 75 string target = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link.IsExternal ? "target=\"_blank\"" : ""; 76 string rel = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link.IsExternal ? "rel=\"noopener\"" : ""; 77 78 string buttonStyle = item.GetRawValueString("ButtonStyle", "primary"); 79 buttonStyle = buttonStyle == "primary" ? "btn-primary" : buttonStyle; 80 buttonStyle = buttonStyle == "secondary" ? "btn-secondary" : buttonStyle; 81 buttonStyle = buttonStyle == "link" ? "btn-link" : buttonStyle; 82 83 return $"<div class=\"m-0\"><a href=\"{link.Url}\" class=\"btn {buttonStyle}{buttonSize} {stretchedLink}\" {target} {rel}>{item.GetString("ButtonLabel")}</a></div>"; 84 } 85 else if (link != null && !string.IsNullOrEmpty(link.Url)) 86 { 87 string target = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link.IsExternal ? "target=\"_blank\"" : ""; 88 string rel = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link.IsExternal ? "rel=\"noopener\"" : ""; 89 90 return $"<a href=\"{link.Url}\" class=\"{stretchedLink}\" {target} {rel}><span class=\"visually-hidden\">{item.GetString("Title")}</span></a>"; 91 } 92 93 return string.Empty; 94 } 95 96 private string RenderCustomCSS(IEnumerable<string> decorations) 97 { 98 var cssClasses = new List<string>(); 99 100 foreach (var itemId in decorations) 101 { 102 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 103 item.TryGetValue("Class", out object classes); 104 105 if (classes is null) 106 { 107 continue; 108 } 109 110 var cssString = (string)classes; 111 112 if (cssString.StartsWith("[")) 113 { 114 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 115 cssClasses.AddRange(cssArray); 116 } 117 else 118 { 119 cssClasses.Add(cssString.Replace(",", " ")); 120 } 121 } 122 123 return string.Join(" ", cssClasses).Trim(); 124 } 125 } 126 127 @{ 128 bool movePageBehind = false; 129 bool isFirstPoster = false; 130 string movePageBehindClass = string.Empty; 131 if (Pageview.Page.PropertyItem != null) 132 { 133 string headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 134 movePageBehind = headerCssClass == "fixed-top" && !Pageview.IsVisualEditorMode ? true : false; 135 if (movePageBehind) 136 { 137 movePageBehindClass = " poster-behind"; 138 if (!Dynamicweb.Context.Current.Items.Contains("firstPosterIsRendered")) 139 { 140 isFirstPoster = true; 141 Dynamicweb.Context.Current.Items.Add("firstPosterIsRendered", true); 142 } 143 } 144 } 145 146 string title = Model.Item.GetString("Title"); 147 var sliderItems = Model.Item?.GetItems("Slider_Items") ?? Enumerable.Empty<Dynamicweb.Frontend.ItemViewModel>().ToList(); 148 149 // Style 150 string buttonSize = Model.Item.GetRawValueString("buttonSize", "regular"); 151 buttonSize = buttonSize == "small" ? " btn-sm" : buttonSize; 152 buttonSize = buttonSize == "regular" ? "" : buttonSize; 153 buttonSize = buttonSize == "large" ? " btn-lg" : buttonSize; 154 string contentPadding = Model.Item.GetRawValueString("ContentPadding", string.Empty); 155 switch (contentPadding) 156 { 157 case "small": 158 contentPadding = " p-3"; 159 break; 160 case "large": 161 contentPadding = " p-4"; 162 break; 163 } 164 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-1"); 165 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 166 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 167 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 168 string css = RenderCustomCSS(decorations); 169 170 // Navgation 171 string slidesPerPage = $"slider-item-show{Model.Item.GetRawValueString("SlidesPerPage", "1")}"; 172 string sliderRatio = Model.Item.GetRawValueString("SliderRatio", "original") != "original" ? $"slider-item-ratio {Model.Item.GetRawValueString("SliderRatio", string.Empty)}" : string.Empty; 173 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}"; 174 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}"; 175 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", string.Empty)}"; 176 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty; 177 string sliderItemsGap = Model.Item.GetRawValueString("SliderItemsGap", "slider-item-gap") == "slider-item-nogap" ? "slider-item-nogap" : string.Empty; 178 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty; 179 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty; 180 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty; 181 string scrollBarForceMobile = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "--swiffy-slider-track-height:0.5rem !important;" : string.Empty; 182 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty; 183 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty; 184 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty; 185 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty; 186 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty; 187 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty; 188 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty; 189 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty; 190 string animation = Model.Item.GetRawValueString("Animation", string.Empty) != string.Empty ? $"slider-nav-animation {Model.Item.GetRawValueString("Animation")}" : string.Empty; 191 string autoplay = (Model.Item.GetBoolean("Autoplay")) ? "slider-nav-autoplay" : string.Empty; 192 string autoplayInterval = Model.Item.GetRawValueString("AutoplayInterval", string.Empty); 193 bool hideSliderNavigation = false; 194 195 var parms = new Dictionary<string, object>(); 196 parms.Add("cssClass", "h-100 w-100"); 197 parms.Add("columns", Model.GridRowColumnCount); 198 199 if (navigationStyle == "slider-nav-none") 200 { 201 hideSliderNavigation = true; 202 } 203 } 204 <div class="h-100 grid gap-0"> 205 <div class="g-col-12 @(css) item_@(Model.Item.SystemName.ToLower())"> 206 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 207 <div id="Slider_@Model.ID" class="swiffy-slider @(sliderRatio) @(slidesPerPage) @(navigationStyle) @(revealSlides) @(navigationPlacement) @(navigationAlwaysVisible) @(navigationVisibleOnTouch) @(sliderItemsGap) @(indicatorStyle) @(navigationShowScrollbar) @(navigationSmall) @(navigationInvertColors) @(indicatorsOutsideSlider) @(navigationNoLoop) @(indicatorsHighlightActive) @(indicatorsInvertColors) @(indicatorsVisibleOnSmallDevices) @(navigationSlideEntirePage) @(animation) @(autoplay) @(theme)@(contentPadding)" style="--swiffy-slider-nav-light:var(--swift-foreground-color);--swiffy-slider-nav-dark:var(--swift-background-color);visibility:hidden;opacity:0;@(scrollBarForceMobile)" data-slider-nav-autoplay-interval="@(autoplayInterval)"> 208 <ul class="slider-container"> 209 @{ 210 bool isFirst = true; 211 parms.Add("alt", string.Empty); 212 } 213 214 @foreach (var item in sliderItems) 215 { 216 isFirst = false; 217 218 string itemLayout = item.GetRawValueString("ItemLayout", "poster"); 219 string layout = item.GetRawValueString("Layout", "align-middle-center-text-center"); 220 string containerWidth = "container-xl"; 221 FileViewModel image = item.GetFile("Image"); 222 int xPos = image?.FocalPositionFromLeft ?? 50; 223 int yPos = image?.FocalPositionFromTop ?? 50; 224 string active = isFirst ? "active" : ""; 225 string alignment = string.Empty; 226 string maxWidth = item.GetRawValueString("TextReadability", "max-width-on"); 227 maxWidth = maxWidth == "max-width-on" ? "style=\"grid-template-columns: minmax(auto,75ch);\"" : maxWidth; 228 maxWidth = maxWidth == "max-width-off" ? string.Empty : maxWidth; 229 string titleColor = item.GetString("TitleColor", "text-inherit"); 230 string titleOpacity = item.GetString("TitleOpacity", "opacity-100"); 231 string subtitleColor = item.GetString("SubtitleColor", "text-inherit"); 232 string subtitleOpacity = item.GetString("SubtitleOpacity", "opacity-100"); 233 string textColor = item.GetString("TextColor", "text-inherit"); 234 string textOpacity = item.GetString("TextOpacity", "opacity-100"); 235 theme = !string.IsNullOrWhiteSpace(item.GetRawValueString("Theme")) && item.GetRawValueString("Theme") != "none" ? " theme " + item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : theme; 236 parms["alt"] = !string.IsNullOrEmpty(item.GetString("ImageAlt")) ? item.GetString("ImageAlt") : item.GetString("Title", string.Empty); 237 238 switch (layout) 239 { 240 case "align-top-left-text-left": 241 alignment = "text-start justify-content-start align-items-start"; 242 break; 243 case "align-top-center-text-center": 244 alignment = "text-center justify-content-center align-items-start"; 245 break; 246 case "align-top-right-text-right": 247 alignment = "text-end justify-content-end align-items-start"; 248 break; 249 case "align-middle-left-text-left": 250 alignment = "text-start justify-content-start align-items-center"; 251 break; 252 case "align-middle-center-text-center": 253 alignment = "text-center justify-content-center align-items-center"; 254 break; 255 case "align-middle-right-text-right": 256 alignment = "text-end justify-content-end align-items-center"; 257 break; 258 case "align-bottom-left-text-left": 259 alignment = "text-start justify-content-start align-items-end"; 260 break; 261 case "align-bottom-center-text-center": 262 alignment = "text-center justify-content-center align-items-end"; 263 break; 264 case "align-bottom-right-text-right": 265 alignment = "text-end justify-content-end align-items-end"; 266 break; 267 } 268 269 switch (itemLayout) 270 { 271 case "poster": 272 273 <li class="@(theme)"> 274 @RenderPartial("Components/Image.cshtml", image ?? new Dynamicweb.Frontend.FileViewModel(), parms) 275 276 @{string position = image is object ? "position-absolute top-0 bottom-0 start-0 end-0 " : string.Empty;} 277 278 <div class="@(position)h-100 grid grid-1 p-3 px-xl-3 py-xl-4 @(containerWidth) @(alignment)" @(maxWidth)> 279 <div class="grid grid-1 gap-3"> 280 @if (!string.IsNullOrEmpty(item.GetString("Title")) && !item.GetBoolean("HideTitle")) 281 { 282 <h2 class="@titleFontSize @titleColor @titleOpacity m-0">@item.GetString("Title")</h2> 283 } 284 @if (!string.IsNullOrEmpty(item.GetString("Subtitle"))) 285 { 286 <p class="@subtitleFontSize @subtitleColor @subtitleOpacity lead m-0">@item.GetString("Subtitle")</p> 287 } 288 @if (!string.IsNullOrEmpty(item.GetString("Text"))) 289 { 290 <div class="mb-0-last-child @textColor @textOpacity">@item.GetString("Text")</div> 291 } 292 @RenderButton(item, buttonSize) 293 </div> 294 </div> 295 </li> 296 297 break; 298 299 case "story-image-left": 300 301 <li class="@(theme)"> 302 <div class="row g-0 h-100"> 303 <div class="col-12 col-lg-6 col-xl-7 mh-100"> 304 <div class="overflow-hidden h-100 w-100"> 305 @RenderPartial("Components/Image.cshtml", image ?? new Dynamicweb.Frontend.FileViewModel(), parms) 306 </div> 307 </div> 308 <div class="col-12 col-lg-6 col-xl-5 mh-100 grid grid-1 p-3 px-xl-3 py-xl-4 @(containerWidth) @(alignment)" @(maxWidth)> 309 <div class="grid grid-1 gap-3"> 310 @if (!string.IsNullOrEmpty(item.GetString("Subtitle"))) 311 { 312 <p class="@subtitleFontSize @subtitleColor @subtitleOpacity lead m-0">@item.GetString("Subtitle")</p> 313 } 314 @if (!string.IsNullOrEmpty(item.GetString("Title")) && !item.GetBoolean("HideTitle")) 315 { 316 <h2 class="@titleFontSize @titleColor @titleOpacity m-0">@item.GetString("Title")</h2> 317 } 318 @if (!string.IsNullOrEmpty(item.GetString("Text"))) 319 { 320 <div class="mb-0-last-child @textColor @textOpacity">@item.GetString("Text")</div> 321 } 322 @RenderButton(item, buttonSize) 323 </div> 324 </div> 325 </div> 326 </li> 327 328 break; 329 330 case "story-image-right": 331 332 <li class="@(theme)"> 333 <div class="row g-0 h-100"> 334 <div class="col-12 col-lg-6 col-xl-5 mh-100 grid grid-1 p-3 px-xl-3 py-xl-4 @(containerWidth) @(alignment)" @(maxWidth)> 335 <div class="grid grid-1 gap-3"> 336 337 @if (!string.IsNullOrEmpty(item.GetString("Subtitle"))) 338 { 339 <p class="@subtitleFontSize @subtitleColor @subtitleOpacity lead m-0">@item.GetString("Subtitle")</p> 340 } 341 @if (!string.IsNullOrEmpty(item.GetString("Title")) && !item.GetBoolean("HideTitle")) 342 { 343 <h2 class="@titleFontSize @titleColor @titleOpacity m-0">@item.GetString("Title")</h2> 344 } 345 @if (!string.IsNullOrEmpty(item.GetString("Text"))) 346 { 347 <div class="mb-0-last-child @textColor @textOpacity">@item.GetString("Text")</div> 348 } 349 @RenderButton(item, buttonSize) 350 </div> 351 </div> 352 <div class="col-12 col-lg-6 col-xl-7 mh-100"> 353 @RenderPartial("Components/Image.cshtml", image ?? new Dynamicweb.Frontend.FileViewModel(), parms) 354 </div> 355 </div> 356 </li> 357 358 break; 359 360 case "logo": 361 362 <li class="@(theme)"> 363 @if (image is object) 364 { 365 var link = GetLink(item); 366 367 if (link is object && !string.IsNullOrEmpty(link.Url)) 368 { 369 string target = link.IsExternal ? "target=\"_blank\"" : string.Empty; 370 <a href="@link.Url" class="d-flex h-100 text-center" @(target)> 371 <img src="@image.Path" class="mw-100 mh-100 m-auto" alt="@(!string.IsNullOrEmpty(item.GetString("ImageAlt")) ? item.GetString("ImageAlt") : item.GetString("Title", string.Empty))" loading="lazy" style="object-fit: contain;"> 372 </a> 373 } 374 else 375 { 376 <div class="d-flex h-100 text-center"> 377 <img src="@image.Path" class="mw-100 mh-100 m-auto" alt="@(!string.IsNullOrEmpty(item.GetString("ImageAlt")) ? item.GetString("ImageAlt") : item.GetString("Title", string.Empty))" loading="lazy" style="object-fit: contain;"> 378 </div> 379 } 380 } 381 </li> 382 383 break; 384 } 385 } 386 </ul> 387 388 @if (!hideSliderNavigation) 389 { 390 <button type="button" title="@Translate("Previous slide")" class="slider-nav" style="z-index:1;"> 391 <span class="visually-hidden">@Translate("Previous slide")</span> 392 </button> 393 <button type="button" title="@Translate("Next slide")" class="slider-nav slider-nav-next" style="z-index:1;"> 394 <span class="visually-hidden">@Translate("Next slide")</span> 395 </button> 396 } 397 398 @if (indicatorStyle != "slider-indicators-hidden") 399 { 400 <div class="slider-indicators" style="z-index:1;"> 401 @{ 402 string isActive = "active"; 403 int slideCount = 1; 404 } 405 406 @foreach (var item in sliderItems) 407 { 408 <button class="@isActive" type="button" title='@Translate("Go to slide") @slideCount'> 409 <span class="visually-hidden">@Translate("Go to slide") @slideCount</span> 410 </button> 411 412 slideCount++; 413 isActive = null; 414 } 415 </div> 416 } 417 </div> 418 419 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 420 <script> 421 window.addEventListener("load", () => { 422 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 423 window.swiffyslider.initSlider(document.querySelector('#Slider_@Model.ID')); 424 document.querySelector('#Slider_@Model.ID').style.opacity = 1; 425 document.querySelector('#Slider_@Model.ID').style.visibility = "visible"; 426 }); 427 </script> 428 </div> 429 </div> 430 431 @if (movePageBehind && isFirstPoster) 432 { 433 <script> 434 ['resize', 'load'].forEach(function (e) { 435 window.addEventListener(e, () => swift.Scroll.setContentPosition()); 436 }); 437 </script> 438 } 439
EN NY BEGYNDELSE

Vi startede som små

Viral mustache cardigan venmo whatever. Semiotics organic leggings, kitsch scenester hot chicken hell of keytar swag cloud bread fanny pack. Chambray artisan wayfarers pour-over. Ascot waistcoat you probably haven't heard of them la croix

red bike
yellow wall
SÆLG I DAG

Og så voksede vi lidt

Viral mustache cardigan venmo whatever. Semiotics organic leggings, kitsch scenester hot chicken hell of keytar swag cloud bread fanny pack. Chambray artisan wayfarers pour-over. Ascot waistcoat you probably haven't heard of them palo santo.

Error executing template "Designs/Swift/Paragraph/Swift_ProductGroupSlider.cshtml"
System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations)
   at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument()
   at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document)
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @functions 5 { 6 private IList<ProductGroupViewModel> GetGroups(string type) 7 { 8 IList<ProductGroupViewModel> groupList = new List<ProductGroupViewModel> { }; 9 10 if (type == "subgroups") 11 { 12 IList<ProductGroupViewModel> groups = Model.Item.GetValue<IList<ProductGroupViewModel>>("Subgroups"); 13 if (groups != null) 14 { 15 foreach (var group in groups) 16 { 17 var subGroups = Dynamicweb.Ecommerce.Services.ProductGroups.GetSubgroups(Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(group.Id)); 18 19 foreach (var subGroup in subGroups) 20 { 21 var subGroupViewModel = Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(new ProductGroupViewModelSettings(), subGroup); 22 groupList.Add(subGroupViewModel); 23 } 24 25 } 26 } 27 } 28 29 if (type == "selected-groups") 30 { 31 IList<ProductGroupViewModel> groups = Model.Item.GetValue<IList<ProductGroupViewModel>>("SelectedGroups"); 32 if (groups != null) 33 { 34 foreach (var group in groups) 35 { 36 groupList.Add(group); 37 } 38 } 39 } 40 41 if (type == "subgroups-current") 42 { 43 var currentGroupId = Dynamicweb.Context.Current.Request.QueryString.Get("GroupID"); 44 var currentGroup = currentGroupId != null ? Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(currentGroupId) : null; 45 var groups = currentGroup != null ? Dynamicweb.Ecommerce.Services.ProductGroups.GetSubgroups(currentGroup) : null; 46 if (groups != null) 47 { 48 foreach (var group in groups) 49 { 50 var groupViewModel = Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(new ProductGroupViewModelSettings(), group); 51 groupList.Add(groupViewModel); 52 } 53 } 54 } 55 56 return groupList; 57 } 58 59 private Dynamicweb.Frontend.LinkViewModel GetLink(ProductGroupViewModel group) 60 { 61 Dynamicweb.Frontend.LinkViewModel link = new Dynamicweb.Frontend.LinkViewModel(); 62 63 link = new Dynamicweb.Frontend.LinkViewModel() 64 { 65 Url = $"/Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={group.Id.Trim()}", 66 IsExternal = false 67 }; 68 69 return link; 70 } 71 } 72 73 @{ 74 var groups = GetGroups(Model.Item.GetRawValueString("GroupType", "subgroups")); 75 string title = Model.Item?.GetString("Title", string.Empty); 76 string subtitle = Model.Item?.GetString("SubTitle", string.Empty); 77 bool hideTitle = Model.Item?.GetBoolean("HideTitle") ?? false; 78 79 // Styling 80 string generalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("GeneralTheme")) ? $"p-3 theme {Model.Item.GetRawValueString("GeneralTheme").Replace(" ", "").Trim().ToLower()}" : string.Empty; 81 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? $"theme {Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower()}" : string.Empty; 82 string alignment = Model.Item.GetRawValueString("Alignment", "align-bottom-center-text-center"); 83 switch (alignment) 84 { 85 case "align-top-left-text-left": 86 alignment = "text-start justify-content-start align-items-start"; 87 break; 88 case "align-top-center-text-center": 89 alignment = "text-center justify-content-center align-items-start"; 90 break; 91 case "align-top-right-text-right": 92 alignment = "text-end justify-content-end align-items-start"; 93 break; 94 case "align-middle-left-text-left": 95 alignment = "text-start justify-content-start align-items-center"; 96 break; 97 case "align-middle-center-text-center": 98 alignment = "text-center justify-content-center align-items-center"; 99 break; 100 case "align-middle-right-text-right": 101 alignment = "text-end justify-content-end align-items-center"; 102 break; 103 case "align-bottom-left-text-left": 104 alignment = "text-start justify-content-start align-items-end"; 105 break; 106 case "align-bottom-center-text-center": 107 alignment = "text-center justify-content-center align-items-end"; 108 break; 109 case "align-bottom-right-text-right": 110 alignment = "text-end justify-content-end align-items-end"; 111 break; 112 } 113 114 // Slider settings (documentation: swiffyslider.com/configuration) 115 string slidesPerPage = $"slider-item-show{Model.Item.GetRawValueString("SlidesPerPage", "5")}"; 116 string sliderRatio = Model.Item.GetRawValueString("SliderRatio", "original") != "original" ? $"slider-item-ratio {Model.Item.GetRawValueString("SliderRatio", string.Empty)}" : string.Empty; 117 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}"; 118 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}"; 119 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", string.Empty)}"; 120 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty; 121 string sliderItemsGap = Model.Item.GetRawValueString("SliderItemsGap", "slider-item-gap") == "slider-item-nogap" ? "slider-item-nogap" : string.Empty; 122 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty; 123 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty; 124 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty; 125 string scrollBarForceMobile = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "--swiffy-slider-track-height:0.5rem !important;" : string.Empty; 126 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty; 127 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty; 128 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty; 129 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty; 130 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty; 131 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty; 132 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty; 133 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty; 134 string animation = Model.Item.GetRawValueString("Animation", string.Empty) != string.Empty ? $"slider-nav-animation {Model.Item.GetRawValueString("Animation")}" : string.Empty; 135 string autoplay = (Model.Item.GetBoolean("Autoplay")) ? "slider-nav-autoplay" : string.Empty; 136 string autoplayInterval = Model.Item.GetRawValueString("AutoplayInterval", string.Empty); 137 bool hideSliderNavigation = false; 138 139 if (navigationStyle == "slider-nav-none") 140 { 141 hideSliderNavigation = true; 142 } 143 144 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 145 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 146 string maxWidth = Model.Item.GetRawValueString("TextReadability", string.Empty); 147 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth; 148 maxWidth = maxWidth == "max-width-off" ? string.Empty : maxWidth; 149 150 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", "primary"); 151 buttonStyle = buttonStyle == "primary" ? "btn-primary" : buttonStyle; 152 buttonStyle = buttonStyle == "secondary" ? "btn-secondary" : buttonStyle; 153 buttonStyle = buttonStyle == "link" ? "btn-link" : buttonStyle; 154 155 string buttonSize = Model.Item.GetRawValueString("buttonSize", "regular"); 156 buttonSize = buttonSize == "small" ? " btn-sm" : buttonSize; 157 buttonSize = buttonSize == "regular" ? string.Empty : buttonSize; 158 buttonSize = buttonSize == "large" ? " btn-lg" : buttonSize; 159 160 string stretchedLink = Model.Item.GetRawValueString("StretchedLink", string.Empty); 161 stretchedLink = stretchedLink == "not-clickable" ? string.Empty : stretchedLink; 162 stretchedLink = stretchedLink == "clickable" ? "stretched-link" : stretchedLink; 163 } 164 165 @if (groups is object && groups.Count != 0) 166 { 167 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 168 169 <div class="h-100 @(generalTheme)"> 170 @if ((!string.IsNullOrEmpty(title) || !string.IsNullOrEmpty(subtitle)) && !hideTitle) 171 { 172 <div class="pb-2 pb-lg-4"> 173 <div class="mb-0-last-child"> 174 @if (!string.IsNullOrEmpty(title)) 175 { 176 <h2 class="@titleFontSize@(maxWidth)">@title</h2> 177 } 178 179 @if (!string.IsNullOrEmpty(subtitle)) 180 { 181 <p class="@subtitleFontSize@(maxWidth)">@subtitle</p> 182 } 183 </div> 184 </div> 185 } 186 187 <div class="item_@(Model.Item.SystemName.ToLower())"> 188 <div id="ProductGroupSlider_@Model.ID" class="swiffy-slider @(sliderRatio) @(slidesPerPage) @(navigationStyle) @(revealSlides) @(navigationPlacement) @(navigationAlwaysVisible) @(navigationVisibleOnTouch) @(sliderItemsGap) @(indicatorStyle) @(navigationShowScrollbar) @(navigationSmall) @(navigationInvertColors) @(indicatorsOutsideSlider) @(navigationNoLoop) @(indicatorsHighlightActive) @(indicatorsInvertColors) @(indicatorsVisibleOnSmallDevices) @(navigationSlideEntirePage) @(animation) @(autoplay)" style="--swiffy-slider-nav-light:var(--swift-foreground-color);--swiffy-slider-nav-dark:var(--swift-background-color);opacity:0;visibility:hidden;@(scrollBarForceMobile)" data-slider-nav-autoplay-interval="@(autoplayInterval)"> 189 <ul class="slider-container"> 190 @foreach (var group in groups) 191 { 192 var groupImage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(group.Id)?.LargeImage; 193 if (groupImage.StartsWith("/") && !groupImage.StartsWith("/Files", StringComparison.OrdinalIgnoreCase)) 194 { 195 groupImage = $"/Files{groupImage}"; 196 } 197 198 groupImage = Dynamicweb.Context.Current.Server.UrlEncode(groupImage); 199 groupImage = !string.IsNullOrEmpty(groupImage) ? $"/Admin/Public/GetImage.ashx?width=640&crop=0&image={groupImage}&format=webp" : string.Empty; 200 201 <li data-group="@group.Id"> 202 <div class="card h-100 border-0 rounded-0 @(theme)"> 203 @if (!string.IsNullOrEmpty(groupImage)) 204 { 205 <img class="card-img rounded-0 h-100" loading="lazy" src="@groupImage" style="object-fit: cover;" alt="@group.Name"> 206 } 207 <div class="@(!string.IsNullOrEmpty(sliderRatio) ? "card-img-overlay " : string.Empty)@(string.IsNullOrEmpty(sliderRatio) && string.IsNullOrEmpty(groupImage) ? "h-100 " : string.Empty)rounded-0 d-grid p-xl-4 @alignment"> 208 @if (GetLink(group) != null) 209 { 210 string target = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && GetLink(group).IsExternal ? "target=\"_blank\"" : ""; 211 string rel = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && GetLink(group).IsExternal ? "rel=\"noopener\"" : ""; 212 213 <div class="m-0"> 214 <a href="@GetLink(group)" class="btn @(buttonSize) @buttonStyle @(stretchedLink)" @target @rel>@group.Name</a> 215 </div> 216 } 217 </div> 218 </div> 219 </li> 220 } 221 </ul> 222 223 @if (!hideSliderNavigation) 224 { 225 <button type="button" title="@Translate("Previous slide")" class="slider-nav" style="z-index:2;"> 226 <span class="visually-hidden">@Translate("Previous slide")</span> 227 </button> 228 <button type="button" title="@Translate("Next slide")" class="slider-nav slider-nav-next" style="z-index:2;"> 229 <span class="visually-hidden">@Translate("Next slide")</span> 230 </button> 231 } 232 233 @if (indicatorStyle != "slider-indicators-hidden") 234 { 235 bool isActive = true; 236 int slideCount = 1; 237 238 <div class="slider-indicators" style="z-index:2;"> 239 @foreach (var group in groups) 240 { 241 <button @(isActive ? "class=\"active\"" : string.Empty) type="button" title='@Translate("Go to slide") @slideCount'> 242 <span class="visually-hidden">@Translate("Go to slide") @slideCount</span> 243 </button> 244 245 slideCount++; 246 isActive = false; 247 } 248 </div> 249 } 250 251 </div> 252 253 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 254 <script> 255 window.addEventListener("load", () => { 256 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 257 window.swiffyslider.initSlider(document.querySelector('#ProductGroupSlider_@Model.ID')); 258 document.querySelector('#ProductGroupSlider_@Model.ID').style.opacity = 1; 259 document.querySelector('#ProductGroupSlider_@Model.ID').style.visibility = "visible"; 260 }); 261 </script> 262 </div> 263 </div> 264 } 265 else if (Pageview.IsVisualEditorMode) 266 { 267 <div class="alert alert-dark" role="alert"> 268 <span>@Translate("Group slider"): @Translate("Edit this column to configure")</span> 269 </div> 270 } 271
UDSALG
Op til

50%

* Fri levering på ordre over DKK 500.

Error executing template "Designs/Swift/Paragraph/Swift_RelatedProducts.cshtml"
System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations)
   at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument()
   at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document)
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } 11 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 12 { 13 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 14 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 15 16 if (productList?.Products is object) 17 { 18 product = productList.Products[0]; 19 } 20 } 21 22 string title = Model?.Item?.GetRawValueString("Title", Translate("Products")); 23 string campaignValues = string.Join(",", Model.Item.GetList("CampaignBadges")?.GetRawValue().OfType<string>().ToList()); 24 25 //Styling 26 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 27 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 28 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", ""); 29 buttonStyle = buttonStyle == "primary" ? " btn-primary" : buttonStyle; 30 buttonStyle = buttonStyle == "secondary" ? " btn-secondary" : buttonStyle; 31 buttonStyle = buttonStyle == "link" ? " btn-link" : buttonStyle; 32 string maxWidth = Model.Item.GetRawValueString("TextReadability", ""); 33 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth; 34 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth; 35 36 string generalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("GeneralTheme")) ? " theme " + Model.Item.GetRawValueString("GeneralTheme").Replace(" ", "").Trim().ToLower() : ""; 37 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 38 string imageTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 39 40 //Link generation 41 string pageId = !string.IsNullOrEmpty(Model.Item.GetRawValueString("ProductSliderServicePage")) ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 42 if (string.IsNullOrEmpty(pageId)) 43 { 44 pageId = GetPageIdByNavigationTag("ProductSliderService").ToString(); 45 } 46 47 string url = "/Default.aspx?ID=" + pageId; 48 if (!url.Contains("LayoutTemplate", StringComparison.OrdinalIgnoreCase)) 49 { 50 url += url.Contains("?") ? "&LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml" : "?LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml"; 51 } 52 if (Pageview.IsVisualEditorMode) 53 { 54 url += "&VisualEdit=True"; 55 } 56 57 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 58 if (isLazyLoadingForProductInfoEnabled) 59 { 60 url += "&getproductinfo=true"; 61 } 62 63 //Source type 64 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 65 IList<string> relateFromGroupIds = new List<string> { }; 66 IList<string> relateFromProductVariantIds = new List<string> { }; 67 IList<string> relateFromProductIds = new List<string> { }; 68 bool hasVariants = false; 69 70 //--- VARIANTS --- 71 if (sourceType == "variants" && Model.Item.GetValue<ProductListViewModel>("ProductsToRelateToVariants") is ProductListViewModel productsToRelateToVariants) 72 { 73 foreach (var productSelection in productsToRelateToVariants.Products) 74 { 75 relateFromProductIds.Add(productSelection.Id); 76 } 77 } 78 79 //--- MOST SOLD --- 80 if (sourceType == "most-sold" && Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToMostSold") is IList<ProductGroupViewModel> groupsToRelateToMostSold) 81 { 82 foreach (var fromGroup in groupsToRelateToMostSold) 83 { 84 relateFromGroupIds.Add(fromGroup.Id); 85 } 86 } 87 88 //--- TRENDING --- 89 if (sourceType == "trending" && Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToTrending") is IList<ProductGroupViewModel> groupsToRelateToTrending) 90 { 91 foreach (var fromGroup in groupsToRelateToTrending) 92 { 93 relateFromGroupIds.Add(fromGroup.Id); 94 } 95 } 96 97 //--- LATEST --- 98 if (sourceType == "latest" && Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToLatest") is IList<ProductGroupViewModel> groupsToRelateToLatest) 99 { 100 foreach (var fromGroup in groupsToRelateToLatest) 101 { 102 relateFromGroupIds.Add(fromGroup.Id); 103 } 104 } 105 106 //--- FREQUENTLY BOUGHT --- 107 if (sourceType == "frequently" && Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo") is ProductListViewModel productsToRelateTo) 108 { 109 foreach (var fromProduct in productsToRelateTo.Products) 110 { 111 relateFromProductIds.Add(fromProduct.Id); 112 } 113 } 114 115 //--- SELECTED PRODUCTS --- 116 if ((sourceType == "selected" || sourceType == "frequently") && Model.Item.GetValue<ProductListViewModel>("Products") is ProductListViewModel products) 117 { 118 hasVariants = products.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 119 foreach (var productSelection in products.Products) 120 { 121 if (hasVariants) 122 { 123 if (!string.IsNullOrEmpty(productSelection.VariantId)) 124 { 125 relateFromProductVariantIds.Add($"{productSelection.Id} {productSelection.VariantId}"); 126 } 127 else 128 { 129 relateFromProductVariantIds.Add($"{productSelection.Id}"); 130 } 131 } 132 relateFromProductIds.Add($"{productSelection.Id}"); 133 } 134 } 135 136 //--- RELATED PRODUCTS --- 137 if (sourceType == "related-products" && Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo2") is ProductListViewModel selectedRelationProduct) 138 { 139 if (selectedRelationProduct.Products.Any()) 140 { 141 product = selectedRelationProduct.Products.FirstOrDefault(); 142 } 143 144 if (product?.RelatedGroups != null) 145 { 146 foreach (var group in product.RelatedGroups) 147 { 148 foreach (var relatedProduct in group.Products) 149 { 150 if (!string.IsNullOrEmpty(relatedProduct.VariantId)) 151 { 152 relateFromProductVariantIds.Add($"{relatedProduct.ProductId} {relatedProduct.VariantId}"); 153 } 154 else 155 { 156 relateFromProductVariantIds.Add($"{relatedProduct.ProductId}"); 157 } 158 } 159 } 160 } 161 } 162 163 //Create group id collection and products id collection strings 164 string groupIds = product is object ? product.PrimaryOrDefaultGroup.Id : string.Join(",", relateFromGroupIds); 165 string productVariantIds = relateFromProductVariantIds.Count > 0 ? string.Join(",", relateFromProductVariantIds) : ""; 166 string productIds = product is object && relateFromProductIds.Count == 0 ? product.Id : string.Join(",", relateFromProductIds); 167 168 //Set the parameters to the url 169 string linkParameters = ""; 170 linkParameters += sourceType != "related-products" && sourceType != "frequently" && sourceType != "selected" ? "&GroupId=" + groupIds : ""; 171 linkParameters += !string.IsNullOrEmpty(productIds) && sourceType != "most-sold" && sourceType != "trending" && sourceType != "latest" && sourceType != "frequently" && sourceType != "related-products" ? "&MainProductId=" + productIds : ""; 172 linkParameters += !string.IsNullOrEmpty(productVariantIds) && sourceType == "related-products" ? "&ProductVariantId=" + productVariantIds : ""; 173 linkParameters += sourceType == "variants" ? "&IsVariant=true" : ""; 174 linkParameters += sourceType == "latest" ? "&SortBy=Created" : ""; 175 linkParameters += sourceType == "most-sold" ? "&SortBy=OrderCount" : ""; 176 linkParameters += sourceType == "trending" ? "&SortBy=OrderCountGrowth" : ""; 177 linkParameters += !string.IsNullOrEmpty(productIds) && sourceType == "frequently" ? $"&BoughtWithProductIds=[{productIds}]" : ""; 178 var productListPageId = GetPageIdByNavigationTag("Shop"); 179 string link = "/Default.aspx?ID=" + productListPageId + linkParameters; 180 181 // Slider settings (documentation: swiffyslider.com/configuration) 182 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}"; 183 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}"; 184 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", "slider-indicators-hidden")}"; 185 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty; 186 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty; 187 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty; 188 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty; 189 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty; 190 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty; 191 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty; 192 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty; 193 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty; 194 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty; 195 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty; 196 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty; 197 198 bool productsFound = true; 199 if (string.IsNullOrEmpty(groupIds) && string.IsNullOrEmpty(productIds) && string.IsNullOrEmpty(productVariantIds)) 200 { 201 if (Pageview.IsVisualEditorMode) 202 { 203 productIds = product.Id; 204 sourceType = "selected"; 205 } 206 else 207 { 208 productsFound = false; 209 } 210 } 211 } 212 213 @*Container element for the request*@ 214 @if (productsFound) 215 { 216 <form method="post" action="@url" id="RelatedProductsForm_@Model.ID" data-response-target-element="RelatedProducts_@Model.ID" data-preloader="inline" data-update-url="false" class="item_@Model.Item.SystemName.ToLower()"> 217 <input type="hidden" name="ModelID" value="@Model.ID"> 218 <input type="hidden" name="SourceType" value="@sourceType"> 219 220 @*--- SLIDER SETTINGS ---*@ 221 <input type="hidden" name="NavigationStyle" value="@navigationStyle"> 222 <input type="hidden" name="NavigationPlacement" value="@navigationPlacement"> 223 <input type="hidden" name="IndicatorStyle" value="@indicatorStyle"> 224 <input type="hidden" name="RevealSlides" value="@revealSlides"> 225 <input type="hidden" name="NavigationAlwaysVisible" value="@(navigationAlwaysVisible)"> 226 <input type="hidden" name="NavigationVisibleOnTouch" value="@(navigationVisibleOnTouch)"> 227 <input type="hidden" name="NavigationShowScrollbar" value="@(navigationShowScrollbar)"> 228 <input type="hidden" name="NavigationSmall" value="@(navigationSmall)"> 229 <input type="hidden" name="NavigationInvertColors" value="@(navigationInvertColors)"> 230 <input type="hidden" name="NavigationNoLoop" value="@(navigationNoLoop)"> 231 <input type="hidden" name="NavigationSlideEntirePage" value="@(navigationSlideEntirePage)"> 232 <input type="hidden" name="IndicatorsOutsideSlider" value="@(indicatorsOutsideSlider)"> 233 <input type="hidden" name="IndicatorsHighlightActive" value="@(indicatorsHighlightActive)"> 234 <input type="hidden" name="IndicatorsInvertColors" value="@(indicatorsInvertColors)"> 235 <input type="hidden" name="IndicatorsVisibleOnSmallDevices" value="@(indicatorsVisibleOnSmallDevices)"> 236 237 @*--- VARIANTS ---*@ 238 @if (sourceType == "variants") 239 { 240 <input type="hidden" name="isVariant" value="true"> 241 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds"> 242 } 243 244 @*--- MOST SOLD ---*@ 245 @if (sourceType == "most-sold") 246 { 247 <input type="hidden" name="SortBy" value="OrderCount"> 248 if (groupIds != "") 249 { 250 <input type="hidden" name="GroupId" value="@groupIds"> 251 } 252 } 253 254 @*--- TRENDING ---*@ 255 @if (sourceType == "trending") 256 { 257 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 258 if (groupIds != "") 259 { 260 <input type="hidden" name="GroupId" value="@groupIds"> 261 } 262 } 263 264 @*--- FREQUENTLY BOUGHT ---*@ 265 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 266 { 267 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 268 } 269 @if (sourceType != "frequently" && hasVariants) 270 { 271 <input type="hidden" name="ProductVariantId" value="@productVariantIds"> 272 } 273 274 @*--- LATEST ---*@ 275 @if (sourceType == "latest") 276 { 277 <input type="hidden" name="SortBy" value="Created"> 278 <input type="hidden" name="GroupId" value="@groupIds"> 279 } 280 281 @*--- SELECTED PRODUCTS ---*@ 282 @if (sourceType == "selected" && !string.IsNullOrEmpty(productIds) && !hasVariants) 283 { 284 <input type="hidden" name="MainProductId" id="MainProductID_@Model.ID" value="@productIds"> 285 } 286 @if (sourceType == "selected" && hasVariants) 287 { 288 <input type="hidden" name="ProductVariantId" value="@productVariantIds"> 289 } 290 291 @*--- RELATED PRODUCTS ---*@ 292 @if (sourceType == "related-products") 293 { 294 <input type="hidden" name="ProductVariantId" id="MainProductID_@Model.ID" value="@productVariantIds"> 295 } 296 297 @* General parameters *@ 298 <input type="hidden" name="Link" value="@link"> 299 <input type="hidden" name="HideTitle" value="@Model.Item.GetString("HideTitle")"> 300 301 @if (Model.Item.GetInt32("ProductsCount") != 0) 302 { 303 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 304 } 305 <input type="hidden" name="HeadingTitle" id="RelatedProductsTitle_@Model.ID" value="@title"> 306 @if (!string.IsNullOrEmpty(Model.Item.GetString("Subtitle"))) 307 { 308 <input type="hidden" name="Subtitle" value="@Model.Item.GetString("Subtitle")"> 309 } 310 @if (!string.IsNullOrEmpty(Model.Item.GetString("LinkText"))) 311 { 312 <input type="hidden" name="LinkText" value="@Model.Item.GetString("LinkText")"> 313 } 314 @if (!string.IsNullOrEmpty(Model.Item.GetString("ImageAspectRatio"))) 315 { 316 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 317 ratio = ratio != "0" ? ratio : ""; 318 <input type="hidden" name="ImageAspectRatio" value="@ratio"> 319 } 320 @if (!string.IsNullOrEmpty(Model.Item.GetString("Layout"))) 321 { 322 <input type="hidden" name="Layout" value="@Model.Item.GetRawValueString("Layout")"> 323 } 324 @if (titleFontSize != "") 325 { 326 <input type="hidden" name="TitleFontSize" value="@titleFontSize"> 327 } 328 @if (subtitleFontSize != "") 329 { 330 <input type="hidden" name="SubtitleFontSize" value="@subtitleFontSize"> 331 } 332 @if (buttonStyle != "") 333 { 334 <input type="hidden" name="ButtonStyle" value="@buttonStyle"> 335 } 336 @if (generalTheme != "") 337 { 338 <input type="hidden" name="GeneralTheme" value="@generalTheme"> 339 } 340 @if (theme != "") 341 { 342 <input type="hidden" name="Theme" value="@theme"> 343 } 344 @if (imageTheme != "") 345 { 346 <input type="hidden" name="ImageTheme" value="@imageTheme"> 347 } 348 @if (!string.IsNullOrEmpty(Model.Item.GetString("ContentPadding"))) 349 { 350 string contentPadding = Model.Item.GetRawValueString("ContentPadding"); 351 <input type="hidden" name="ContentPadding" value="@contentPadding"> 352 } 353 <input type="hidden" name="TextReadability" value="@maxWidth"> 354 <input type="hidden" name="ParentColumnSize" id="ParentColumnSize_@Model.ID" value="12"> 355 356 <input type="hidden" name="SaleBadgeType" value="@Model.Item.GetRawValue("SaleBadgeType")"> 357 <input type="hidden" name="SaleBadgeCssClassName" value="@Model.Item.GetRawValue("SaleBadgeDesign")"> 358 <input type="hidden" name="NewBadgeCssClassName" value="@Model.Item.GetRawValue("NewBadgeDesign")"> 359 <input type="hidden" name="NewPublicationDays" value="@Model.Item.GetInt32("NewPublicationDays")"> 360 361 @if (campaignValues != string.Empty) 362 { 363 <input type="hidden" name="CampaignBadgesValues" value="@campaignValues"> 364 } 365 </form> 366 367 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 368 <script> 369 window.addEventListener("load", () => { 370 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 371 }); 372 </script> 373 374 if (Pageview.IsVisualEditorMode) 375 { 376 <div class="alert alert-info" role="alert"> 377 <span>@Translate("Product slider: Edit this column to configure")</span> 378 </div> 379 } 380 381 if (sourceType != "related-products") 382 { 383 <div class="w-100 h-100"> 384 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 385 <div id="RelatedProducts_@Model.ID" class="h-100 swift_product_slider_container"></div> 386 </div> 387 } 388 else if (product?.RelatedGroups != null) 389 { 390 @* Create multiple slider containers, if type is Product relation *@ 391 <div class="grid w-100 h-100@(generalTheme)" style="grid-row-gap: 4rem"> 392 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 393 @foreach (var group in product.RelatedGroups) 394 { 395 <div id="RelatedProducts_@(Model.ID)_@group.Id" class="g-col-12 h-100 swift_product_slider_container"></div> 396 } 397 </div> 398 } 399 400 @* Initialize *@ 401 if (sourceType != "related-products") 402 { 403 <script type="module"> 404 if (document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]")) { 405 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]").getAttribute("data-col-size"); 406 } 407 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID")).then(function () { 408 setTimeout(function() { 409 const isVisualEditor = @(Converter.ToString(Pageview.IsVisualEditorMode).ToLowerInvariant()); 410 const productSliderContainer = document.querySelector(".swift_product_slider_container"); 411 412 if (productSliderContainer && productSliderContainer.innerHTML !== "") { 413 productSliderContainer.classList.remove("d-none"); 414 } 415 else if (!isVisualEditor) { 416 productSliderContainer.closest("[class*=column]").classList.add("d-none"); 417 } 418 }, 150); 419 }); 420 </script> 421 } 422 else if (product?.RelatedGroups != null) 423 { 424 @* Create multiple sliders, if type is Product relation *@ 425 foreach (var group in product.RelatedGroups) 426 { 427 IList<string> fromProductIds = new List<string> { }; 428 429 foreach (var relatedProduct in group.Products) 430 { 431 if (!string.IsNullOrEmpty(relatedProduct.VariantId)) 432 { 433 fromProductIds.Add($"{relatedProduct.ProductId} {relatedProduct.VariantId}"); 434 } 435 else 436 { 437 fromProductIds.Add($"{relatedProduct.ProductId}"); 438 } 439 } 440 <script type="module"> 441 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@(Model.ID)_@group.Id").closest("[data-col-size]").getAttribute("data-col-size"); 442 document.querySelector("#MainProductID_@Model.ID").value = "@string.Join(",", fromProductIds)"; 443 document.querySelector("#RelatedProductsTitle_@Model.ID").value = "@group.Name"; 444 document.querySelector("#RelatedProductsForm_@Model.ID").setAttribute("data-response-target-element", "RelatedProducts_@(Model.ID)_@group.Id"); 445 446 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID")); 447 </script> 448 } 449 } 450 } 451
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/3Columns.cshtml"
System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations)
   at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument()
   at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document)
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.GridRowViewModel> 2 @using Dynamicweb.Content.Items 3 4 @{ 5 string sectionClass = "py-3"; 6 string spaceBetweenRows = Model.Item.GetRawValueString("SpaceBetweenRows", "spacing"); 7 string spaceBetweenRowsMobile = Model.Item.GetRawValueString("SpaceBetweenRowsMobile", "auto"); 8 9 //Row spacing mobile auto 10 if (spaceBetweenRowsMobile == "auto") { 11 spaceBetweenRowsMobile = spaceBetweenRows; 12 } 13 14 //Row spacing mobile 15 switch (spaceBetweenRowsMobile) { 16 case "none": //No spacing 17 sectionClass = "py-0"; 18 break; 19 case "spacing": //Small spacing top and bottom 20 sectionClass = "py-3"; 21 break; 22 case "spacing-small-top": //Small spacing top 23 sectionClass = "pt-3"; 24 break; 25 case "spacing-small-bottom": //Small spacing bottom 26 sectionClass = "pb-3"; 27 break; 28 case "spacing-medium": //Medium spacing top and bottom 29 sectionClass = "py-4"; 30 break; 31 case "spacing-medium-top": //Medium spacing top 32 sectionClass = "pt-4"; 33 break; 34 case "spacing-medium-bottom": //Medium spacing bottom 35 sectionClass = "pb-4"; 36 break; 37 case "spacing-large": //Large spacing top and bottom 38 sectionClass = "py-5"; 39 break; 40 case "spacing-top": //Large spacing top 41 sectionClass = "pt-5"; 42 break; 43 case "spacing-bottom": //Large spacing bottom 44 sectionClass = "pb-5"; 45 break; 46 } 47 48 //Row spacing dekstop 49 switch (spaceBetweenRows) { 50 case "none": //No spacing 51 sectionClass += " py-lg-0"; 52 break; 53 case "spacing": //Small spacing top and bottom 54 sectionClass += " py-lg-3"; 55 break; 56 case "spacing-small-top": //Small spacing top 57 sectionClass += " pt-lg-3 pb-lg-0"; 58 break; 59 case "spacing-small-bottom": //Small spacing bottom 60 sectionClass += " pb-lg-3 pt-lg-0"; 61 break; 62 case "spacing-medium": //Medium spacing top and bottom 63 sectionClass += " py-lg-5"; 64 break; 65 case "spacing-medium-top": //Medium spacing top 66 sectionClass += " pt-lg-5 pb-lg-0"; 67 break; 68 case "spacing-medium-bottom": //Medium spacing bottom 69 sectionClass += " pb-lg-5 pt-lg-0"; 70 break; 71 case "spacing-large": //Large spacing top and bottom 72 sectionClass += " py-lg-6"; 73 break; 74 case "spacing-top": //Large spacing top 75 sectionClass += " pt-lg-6 pb-lg-0"; 76 break; 77 case "spacing-bottom": //Large spacing bottom 78 sectionClass += " pb-lg-6 pt-lg-0"; 79 break; 80 } 81 82 string width = Model.Item.GetRawValueString("Width", "").ToLower(); 83 string containerClass = "container-xl"; 84 if (width == "stretch") 85 { 86 containerClass = "container-fluid"; 87 } 88 if (width == "none") 89 { 90 containerClass = "container-fluid px-0"; 91 } 92 if (width == "compressed") 93 { 94 containerClass = " container-compressed"; 95 } 96 97 string rowClass = string.Empty; 98 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", string.Empty).ToLower(); 99 string spaceBetweenColumnsMobile = Model.Item.GetRawValueString("SpaceBetweenColumnsMobile", string.Empty).ToLower(); 100 //Mobile 101 if (spaceBetweenColumnsMobile == "auto") 102 { 103 spaceBetweenColumnsMobile = spaceBetweenColumns; 104 } 105 if (spaceBetweenColumnsMobile == "stick") { 106 rowClass = " gap-0"; 107 } 108 if (spaceBetweenColumnsMobile == "spacing-medium") 109 { 110 rowClass = " gap-4"; 111 } 112 if (spaceBetweenColumnsMobile == "spacing-large") { 113 rowClass = " gap-5"; 114 } 115 //Desktop 116 if (spaceBetweenColumns == "stick") { 117 rowClass += " gap-lg-0"; 118 } 119 if (spaceBetweenColumns == "spacing-medium") 120 { 121 rowClass += " gap-lg-4"; 122 } 123 if (spaceBetweenColumns == "spacing-large") { 124 rowClass += " gap-lg-5"; 125 } 126 127 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 128 129 string animationOnScrollCol1 = Model.Item.GetRawValueString("AnimationOnScrollCol1", "no-animation"); 130 animationOnScrollCol1 = animationOnScrollCol1 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol1 + "'" : ""; 131 string animationOnScrollCol2 = Model.Item.GetRawValueString("AnimationOnScrollCol2", "no-animation"); 132 animationOnScrollCol2 = animationOnScrollCol2 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol2 + "'" : ""; 133 string animationOnScrollCol3 = Model.Item.GetRawValueString("AnimationOnScrollCol3", "no-animation"); 134 animationOnScrollCol3 = animationOnScrollCol3 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol3 + "'" : ""; 135 136 string hideOverflow = " overflow-hidden"; 137 hideOverflow = 138 animationOnScrollCol1 != "" || 139 animationOnScrollCol2 != "" || 140 animationOnScrollCol3 != "" 141 ? hideOverflow : ""; 142 143 Dynamicweb.Frontend.FileViewModel backgroundImage = Model.Item.GetFile("BackgroundImage"); 144 string backgroundImagePath = backgroundImage?.Path ?? string.Empty; 145 backgroundImagePath = !string.IsNullOrEmpty(backgroundImagePath) ? $"/Admin/Public/GetImage.ashx?image={backgroundImagePath}&width=2600&format=webp&compression=75" : string.Empty; 146 backgroundImagePath = Dynamicweb.Core.Encoders.HtmlEncoder.UrlPathEncode(backgroundImagePath); 147 string backgroundRepeat = Model.Item.GetRawValueString("BackgroundImageRepeat", "no-repeat"); 148 string backgroundImageSize = Model.Item.GetRawValueString("BackgroundImageSize", "initial"); 149 int xPos = backgroundImage?.FocalPositionFromLeft ?? 50; 150 int yPos = backgroundImage?.FocalPositionFromTop ?? 50; 151 string cssPosition = $"{xPos}% {yPos}%"; 152 string gradient = Model.Item.GetRawValueString("Gradient", string.Empty); 153 string gradientOpacity = Model.Item.GetRawValueString("GradientOpacity", "0.00"); 154 string gradientString = "linear-gradient(" + gradient + "deg," + "rgba(var(--swift-foreground-color-rgb)," + gradientOpacity + "), rgba(var(--swift-background-color-rgb)," + gradientOpacity + "))"; 155 string backgroundImageString = "url(" + backgroundImagePath + ")"; 156 string backgroundImagePositionString = "background-position:" + cssPosition + ";"; 157 string backgroundRepeatString = "background-repeat:" + backgroundRepeat + ";"; 158 string backgroundImageSizeString = "background-size:" + backgroundImageSize + ";"; 159 string styleString = string.Empty; 160 161 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 162 var css = string.Empty; 163 var cssClasses = new List<string> { }; 164 165 foreach (var itemId in decorations) 166 { 167 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 168 item.TryGetValue("Class", out object classes); 169 if (classes is null) 170 { 171 continue; 172 } 173 174 var cssString = (string)classes; 175 if (cssString.StartsWith("[")) 176 { 177 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 178 cssClasses.AddRange(cssArray); 179 } 180 else 181 { 182 cssClasses.Add(cssString.Replace(",", " ")); 183 } 184 } 185 css = string.Join(" ", cssClasses).Trim(); 186 187 @* Only gradient *@ 188 189 if (!string.IsNullOrEmpty(gradient) && string.IsNullOrEmpty(backgroundImagePath) && gradientOpacity != ("0.00")) 190 { 191 styleString += "style=\"background-image:" + gradientString + ";\""; 192 } 193 194 @* Only background image *@ 195 196 else if (string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath)) 197 { 198 styleString += "style=\"background-image:" + backgroundImageString + "; " + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\""; 199 } 200 201 @* Gradient and background image *@ 202 203 else if (!string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath)) 204 { 205 styleString += "style=\"background-image:" + gradientString + "," + backgroundImageString + ";" + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\""; 206 } 207 208 int mobileColumnSize = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileColumnBehaviour", "1")); 209 int mobileOrderFirst = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileOrderFirst", "1")); 210 211 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(Model.Column(1).Output()) || !string.IsNullOrWhiteSpace(Model.Column(2).Output()) || !string.IsNullOrWhiteSpace(Model.Column(3).Output())) 212 { 213 <div class="@(sectionClass)@(theme) @(css) item_@Model.Item.SystemName.ToLower()" @styleString data-swift-gridrow> 214 <div class="@containerClass@(hideOverflow)"> 215 <div class="grid grid-@(mobileColumnSize) grid-lg-@Model.Columns.Count()@(rowClass)"> 216 <div class="g-col @(Model.Column(1).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="4" @animationOnScrollCol1 style="--bs-columns:12"> 217 @Model.Column(1).Output() 218 </div> 219 <div class="g-col @(Model.Column(2).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="4" @animationOnScrollCol2 style="--bs-columns:12"> 220 @Model.Column(2).Output() 221 </div> 222 <div class="g-col @(Model.Column(3).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="4" @animationOnScrollCol3 style="--bs-columns:12"> 223 @Model.Column(3).Output() 224 </div> 225 </div> 226 </div> 227 </div> 228 } 229 } 230

Ad

Gatekeep bespoke blackbird spyplane

A limited-edition masterpiece blending sleek design, cutting-edge materials, and unmatched exclusivity. Featuring a matte black carbon-fiber finish, customizable accents, and collector’s certification, this 1:50 scale icon is the ultimate statement for aviation enthusiasts. Available by request only.

Error executing template "CookieWarning/Cookies.cshtml"
System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations)
   at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder)
   at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument()
   at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document)
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Environment; 3 4 @{ 5 var categories = CookieManager.GetCategories(); 6 7 string cookieNoticeLink = Pageview.AreaSettings.GetLink("CookiePolicyLink") != null ? Pageview.AreaSettings.GetLink("CookiePolicyLink").Url : ""; 8 string privacyPolicyLink = Pageview.AreaSettings.GetLink("PrivacyPolicyLink") != null ? Pageview.AreaSettings.GetLink("PrivacyPolicyLink").Url : ""; 9 int cookieNoticePageID = Pageview.AreaSettings.GetLink("CookiePolicyLink") != null ? Pageview.AreaSettings.GetLink("CookiePolicyLink").PageId : 0; 10 int privacyPolicyPageID = Pageview.AreaSettings.GetLink("PrivacyPolicyLink") != null ? Pageview.AreaSettings.GetLink("PrivacyPolicyLink").PageId : 0; 11 string googleTagManagerID = Pageview.AreaSettings.GetString("GoogleTagManagerID"); 12 13 string layout = Pageview.AreaSettings.GetRawValueString("CookieLayout", "modal"); 14 15 layout = Pageview.Page.ID == cookieNoticePageID || Pageview.Page.ID == privacyPolicyPageID ? "both" : layout; 16 } 17 18 @if (!Pageview.IsVisualEditorMode) { 19 if (layout == "banner" || layout == "both") 20 { 21 string bannerTheme = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetRawValueString("CookieBannerTheme")) ? " theme " + Pageview.AreaSettings.GetRawValueString("CookieBannerTheme").Replace(" ", "").Trim().ToLower() : "theme light"; 22 23 <div class="position-fixed bottom-0 w-100 shadow @bannerTheme" id="dwCookieBanner"> 24 <div class="align-items-center grid p-3"> 25 @if (layout == "banner") 26 { 27 <div class="g-col-12 g-col-md-6 g-col-lg-8"> 28 <span>@Translate("By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing")</span> 29 </div> 30 <div class="g-col-12 g-col-md-6 g-col-lg-4"> 31 <div class="grid grid-1 grid-sm-2"> 32 <button type="button" onclick="setOptInCookie(2)" class="btn btn-primary" id="CookiesAcceptAll"> 33 @Translate("Accept all") 34 </button> 35 <button type="button" onclick="setOptInCookie(1)" class="btn btn-secondary" id="CookiesDeclineAll"> 36 @Translate("Decline") 37 </button> 38 </div> 39 </div> 40 } 41 @if (layout == "both") 42 { 43 <div class="g-col-12 g-col-lg-6 g-col-xxl-8"> 44 <span>@Translate("By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing")</span> 45 </div> 46 <div class="g-col-12 g-col-lg-6 g-col-xxl-4"> 47 <div class="grid grid-1 grid-sm-3"> 48 <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#dwCookieModal"> 49 @Translate("Customize settings") 50 </button> 51 <button type="button" onclick="setOptInCookie(2)" class="btn btn-secondary" id="CookiesAcceptAll"> 52 @Translate("Accept all") 53 </button> 54 <button type="button" onclick="setOptInCookie(1)" class="btn btn-secondary" id="CookiesDeclineAll"> 55 @Translate("Decline") 56 </button> 57 </div> 58 </div> 59 } 60 </div> 61 </div> 62 } 63 64 if (layout == "modal" || layout == "both") 65 { 66 string modalTheme = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetRawValueString("CookieModalTheme")) ? " theme " + Pageview.AreaSettings.GetRawValueString("CookieModalTheme").Replace(" ", "").Trim().ToLower() : "theme light"; 67 68 <div class="modal fade" id="dwCookieModal"> 69 <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" style="max-width:560px;"> 70 <div class="modal-content @modalTheme"> 71 <div style="overflow-y:auto;overflow-x:hidden"> 72 <div class="p-3 p-md-4 overflow-auto" style="max-height:50vh;"> 73 <div class="h3 mb-3">@Translate("You control your data")</div> 74 <p>@Translate("We and our partners use technologies, including cookies, to collect information about you for various purposes, including"):</p> 75 <ol> 76 <li>@Translate("Functionality")</li> 77 <li>@Translate("Statistics")</li> 78 <li>@Translate("Marketing")</li> 79 </ol> 80 <p>@Translate("By clicking 'Accept All' you consent to all these purposes. You can also choose to indicate what purposes you will consent to using the custom selections and then click 'Accept selected'").</p> 81 82 @if (!string.IsNullOrEmpty(cookieNoticeLink) || !string.IsNullOrEmpty(privacyPolicyLink)) 83 { 84 <p>@Translate("You can read more about our use of cookies and other technologies, as well as our collection and processing of personal data by clicking here"):</p> 85 } 86 87 @if (!string.IsNullOrEmpty(cookieNoticeLink)) 88 { 89 <a href="@cookieNoticeLink" class="d-block mb-3" id="CookiesReadModeAbout">@Translate("Read more about Cookies")</a> 90 } 91 @if (!string.IsNullOrEmpty(privacyPolicyLink)) 92 { 93 <a href="@privacyPolicyLink" class="d-block" id="CookiesPrivacyPolicy">@Translate("Our privacy policy")</a> 94 } 95 </div> 96 97 <div class="p-3 px-md-4 border-top"> 98 <div class="grid grid-1 grid-sm-2 gap-3"> 99 <button type="button" onclick="setOptInCookie(1)" class="btn btn-secondary" data-bs-dismiss="modal" id="dwCookieDeclineAll">@Translate("Decline")</button> 100 @if (categories.Any()) 101 { 102 <button type="button" onclick="acceptCustomSetup()" class="btn btn-secondary d-none" data-bs-dismiss="modal" id="dwCookieAcceptSelected">@Translate("Accept selected")</button> 103 } 104 <button type="button" onclick="setOptInCookie(2)" class="btn btn-secondary" data-bs-dismiss="modal" id="dwCookieAcceptAll">@Translate("Accept All")</button> 105 </div> 106 </div> 107 108 @if (categories.Any()) 109 { 110 int categoriesCount = 0; 111 int totalCategories = categories.Count(); 112 113 <form id="dwCookieModalCustomForm" method="post" action="/Admin/Public/CookieOptInLevelConfig.aspx"> 114 <input type="hidden" name="cmd" value="SetCookieOptInLevel"> 115 <input type="hidden" name="OptInLevel" id="OptInLevel" value="1"> 116 <div class="grid grid-2 grid-sm-4 gap-0 px-md-3 border-top border-1"> 117 <div class="p-3"> 118 <label class="form-check-label" for="dwCookieNecessary"><span>@Translate("Necessary")</span></label> 119 <div class="form-check form-switch form-control-lg py-0"> 120 <input class="form-check-input opacity-100" type="checkbox" id="dwCookieNecessary" checked disabled style="background-color: rgba(0,0,0,0.1);"> 121 </div> 122 </div> 123 @foreach (var category in categories) 124 { 125 string border = categoriesCount < (totalCategories - 1) ? "" : ""; 126 127 <div class="p-3 @(border)"> 128 <label class="form-check-label" for="CookieCategory_@category"><span>@Translate(category)</span></label> 129 <div class="form-check form-switch form-control-lg py-0"> 130 <input class="form-check-input js-checkbox" type="checkbox" name="OptInCategory" value="@category" id="CookieCategory_@category" onchange="toggleAcceptSelected()" style="background-color: rgba(0,0,0,0.1);"> 131 </div> 132 </div> 133 categoriesCount++; 134 } 135 </div> 136 </form> 137 } 138 </div> 139 </div> 140 </div> 141 </div> 142 } 143 144 145 <script> 146 async function setOptInCookie(optInLevel) { 147 let response = await fetch("/admin/public/CookieOptInLevelConfig.aspx?cmd=SetCookieOptInLevel&OptInLevel=" + optInLevel); 148 @if (!string.IsNullOrWhiteSpace(googleTagManagerID)){ <text> 149 if (optInLevel == '2') { 150 consentGrantedAll(); 151 } 152 </text> 153 } 154 155 if (response.ok) { 156 if (document.querySelector("#dwCookieBanner")) { 157 document.querySelector("#dwCookieBanner").classList.add("d-none"); 158 } 159 document.location.reload(); 160 return false; 161 } else { 162 return false; 163 } 164 } 165 166 async function acceptCustomSetup() { 167 var form = document.querySelector("#dwCookieModalCustomForm"); 168 169 let formData = new FormData(form); 170 var fetchOptions = { 171 method: 'POST', 172 body: formData 173 }; 174 175 for (const value of formData.values()) { 176 console.log(value); 177 if (value == 'Marketing') { console.log('Granting marketing cookies') consentGrantedMarketing(); 178 } 179 if (value == 'Statistical') { 180 console.log('Granting statistical cookies') 181 consentGrantedAnalyticsStorage(); 182 } 183 } 184 185 186 let response = await fetch(form.action, fetchOptions); 187 188 if (response.ok) { 189 if (document.querySelector("#dwCookieBanner")) { 190 document.querySelector("#dwCookieBanner").classList.add("d-none"); 191 } 192 document.location.reload(); 193 return false; 194 } else { 195 return false; 196 } 197 } 198 199 200 function consentGrantedAll() { 201 consentGrantedMarketing(); 202 consentGrantedAnalyticsStorage(); 203 } 204 function consentGrantedMarketing() { 205 consentGrantedAdStorage(); 206 consentGrantedAdUserData(); 207 consentGrantedAdPersonalization(); 208 } 209 210 function consentGrantedAdStorage() { 211 if (!window.dataLayer) return; 212 gtag('consent', 'update', { 213 'ad_storage': 'granted' 214 }); 215 } 216 217 function consentGrantedAdUserData() { 218 if (!window.dataLayer) return; 219 gtag('consent', 'update', { 220 'ad_user_data': 'granted' 221 }); 222 } 223 224 function consentGrantedAdPersonalization() { 225 if (!window.dataLayer) return; 226 gtag('consent', 'update', { 227 'ad_personalization': 'granted' 228 }); 229 } 230 231 function consentGrantedAnalyticsStorage() { 232 if (!window.dataLayer) return; 233 gtag('consent', 'update', { 234 'analytics_storage': 'granted' 235 }); 236 } 237 238 function toggleAcceptSelected() { 239 var cookieCalegoriesElement = document.querySelector("#dwCookieModalCustomForm"); 240 var enableAcceptSelected = false; 241 242 cookieCalegoriesElement.querySelectorAll(".js-checkbox").forEach(function (field) { 243 if (field.checked == true) { 244 enableAcceptSelected = true; 245 } 246 }); 247 248 if (enableAcceptSelected) { 249 document.querySelector("#dwCookieDeclineAll").classList.add("d-none"); 250 document.querySelector("#dwCookieAcceptSelected").classList.remove("d-none"); 251 } else { 252 document.querySelector("#dwCookieDeclineAll").classList.remove("d-none"); 253 document.querySelector("#dwCookieAcceptSelected").classList.add("d-none"); 254 } 255 } 256 257 function showCookieModal() { 258 var cookieModal = new bootstrap.Modal(document.querySelector('#dwCookieModal'), { 259 backdrop: 'static' 260 }); 261 cookieModal.show(); 262 } 263 </script> 264 265 if (layout == "modal") 266 { 267 <script type="module"> 268 showCookieModal(); 269 </script> 270 } 271 } 272