Error executing template "/Designs/Swift/Grid/Page/RowTemplates/1ColumnFlex.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 @{ 3 string containerClass = "container-xl"; 4 5 string width = Model.Item.GetRawValueString("Width", ""); 6 if (width == "stretch") { 7 containerClass = "container-fluid"; 8 } 9 if (width == "none") { 10 containerClass = "container-fluid px-0"; 11 } 12 13 string rowHeight = Model.Item.GetRawValueString("RowHeight", "0"); 14 rowHeight = "py-" + rowHeight; 15 16 string hideOnScroll = Model.Item.GetRawValueString("HideOnScroll", string.Empty).ToLower(); 17 hideOnScroll = hideOnScroll == "hide" ? "js-hide-on-scroll" : ""; 18 19 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 20 string alternativeTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("AlternativeTheme")) ? " theme " + Model.Item.GetRawValueString("AlternativeTheme").Replace(" ", "").Trim().ToLower() : ""; 21 string mainTheme = theme; 22 23 string headerCssClass = "sticky-top"; 24 if (Pageview.Page.PropertyItem is Dynamicweb.Content.Items.Item propertyItem ) { 25 headerCssClass = propertyItem["MoveThisPageBehindTheHeader"] != null ? propertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 26 } 27 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 28 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 29 30 string themeSwitchers = ""; 31 string themeAnimated = ""; 32 if (headerCssClass == "fixed-top") { 33 theme = alternativeTheme; 34 themeSwitchers = "data-main-theme=\"" + mainTheme + "\" data-alternative-theme=\"" + alternativeTheme + "\""; 35 themeAnimated = "theme-animated "; 36 } 37 38 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 39 var css = string.Empty; 40 var cssClasses = new List<string> { }; 41 42 foreach (var itemId in decorations) 43 { 44 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 45 item.TryGetValue("Class", out object classes); 46 if (classes is null) 47 { 48 continue; 49 } 50 51 var cssString = (string)classes; 52 if (cssString.StartsWith("[")) 53 { 54 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 55 cssClasses.AddRange(cssArray); 56 } 57 else 58 { 59 cssClasses.Add(cssString.Replace(",", " ")); 60 } 61 } 62 css = string.Join(" ", cssClasses).Trim(); 63 64 var columnContent = Model.Column(1).Output(); 65 66 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnContent)) 67 { 68 <div class="@rowHeight @themeAnimated @theme @hideOnScroll @(css) item_@Model.Item.SystemName.ToLower()" @themeSwitchers data-swift-gridrow> 69 <div class="@containerClass"> 70 <div class="d-flex flex-row"> 71 <div class="col"> 72 @columnContent 73 </div> 74 </div> 75 </div> 76 </div> 77 } 78 } 79
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/2ColumnsFlex.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 3 @{ 4 string containerClass = "container-xl"; 5 6 string width = Model.Item.GetRawValueString("Width", "").ToLower(); 7 if (width == "stretch") 8 { 9 containerClass = "container-fluid"; 10 } 11 if (width == "none") 12 { 13 containerClass = "container-fluid px-0"; 14 } 15 16 string rowClass = "gap-3"; 17 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", "").ToLower(); 18 19 if (spaceBetweenColumns == "stick") 20 { 21 rowClass = "gap-0"; 22 } 23 if (spaceBetweenColumns == "spacing-large") 24 { 25 rowClass = "gap-1 gap-md-4 gap-lg-5"; 26 } 27 28 string columnPosition = Model.Item.GetRawValueString("ColumnPosition", "align-items-center").ToLower(); 29 if (columnPosition == "top") 30 { 31 columnPosition = "align-items-start"; 32 } 33 if (columnPosition == "center") 34 { 35 columnPosition = "align-items-center"; 36 } 37 if (columnPosition == "bottom") 38 { 39 columnPosition = "align-items-end"; 40 } 41 42 string rowHeight = Model.Item.GetRawValueString("RowHeight", "0").ToLower(); 43 rowHeight = "py-" + rowHeight; 44 45 string column1width = Model.Item.GetRawValueString("Column_1Width", "").ToLower(); 46 column1width = column1width == "grow" ? "flex-grow-1" : "flex-grow-0"; 47 48 string column2width = Model.Item.GetRawValueString("Column_2Width", "").ToLower(); 49 column2width = column2width == "grow" ? "flex-grow-1" : "flex-grow-0"; 50 51 string hideOnScroll = Model.Item.GetRawValueString("HideOnScroll", "").ToLower(); 52 hideOnScroll = hideOnScroll == "hide" ? "js-hide-on-scroll" : ""; 53 54 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 55 string alternativeTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("AlternativeTheme")) ? " theme " + Model.Item.GetRawValueString("AlternativeTheme").Replace(" ", "").Trim().ToLower() : ""; 56 string mainTheme = theme; 57 58 string headerCssClass = "sticky-top"; 59 if (Pageview.Page.PropertyItem != null) { 60 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 61 } 62 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 63 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 64 65 string themeSwitchers = ""; 66 string themeAnimated = ""; 67 if (headerCssClass == "fixed-top") 68 { 69 theme = alternativeTheme; 70 themeSwitchers = "data-main-theme=\"" + mainTheme + "\" data-alternative-theme=\"" + alternativeTheme + "\""; 71 themeAnimated = "theme-animated "; 72 } 73 74 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 75 var css = string.Empty; 76 var cssClasses = new List<string> { }; 77 78 foreach (var itemId in decorations) 79 { 80 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 81 item.TryGetValue("Class", out object classes); 82 if (classes is null) 83 { 84 continue; 85 } 86 87 var cssString = (string)classes; 88 if (cssString.StartsWith("[")) 89 { 90 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 91 cssClasses.AddRange(cssArray); 92 } 93 else 94 { 95 cssClasses.Add(cssString.Replace(",", " ")); 96 } 97 } 98 css = string.Join(" ", cssClasses).Trim(); 99 100 var columnContent1 = Model.Column(1).Output(); 101 var columnContent2 = Model.Column(2).Output(); 102 103 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnContent1) || !string.IsNullOrWhiteSpace(columnContent2)) 104 { 105 <div class="@rowHeight @themeAnimated @theme @hideOnScroll @(css) item_@Model.Item.SystemName.ToLower()" @themeSwitchers data-swift-gridrow> 106 <div class="@containerClass"> 107 <div class="d-flex flex-row @rowClass @columnPosition"> 108 <div class="col @column1width"> 109 @columnContent1 110 </div> 111 <div class="col @column2width"> 112 @columnContent2 113 </div> 114 </div> 115 </div> 116 </div> 117 } 118 } 119
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/5ColumnsFlex.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 3 @{ 4 string containerClass = "container-xl"; 5 6 string width = Model.Item.GetRawValueString("Width", string.Empty).ToLower(); 7 if (width == "stretch") 8 { 9 containerClass = "container-fluid"; 10 } 11 if (width == "none") 12 { 13 containerClass = "container-fluid px-0"; 14 } 15 16 string rowClass = "gap-3"; 17 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", "").ToLower(); 18 19 if (spaceBetweenColumns == "stick") 20 { 21 rowClass = "gap-0"; 22 } 23 if (spaceBetweenColumns == "spacing-large") 24 { 25 rowClass = "gap-3 gap-md-4 gap-lg-5"; 26 } 27 28 string columnPosition = Model.Item.GetRawValueString("columnPosition", "align-items-center").ToLower(); 29 if (columnPosition == "top") 30 { 31 columnPosition = "align-items-start"; 32 } 33 if (columnPosition == "center") 34 { 35 columnPosition = "align-items-center"; 36 } 37 if (columnPosition == "bottom") 38 { 39 columnPosition = "align-items-end"; 40 } 41 42 string rowHeight = Model.Item.GetRawValueString("RowHeight", "0").ToLower(); 43 rowHeight = "py-" + rowHeight; 44 45 string column1width = Model.Item.GetRawValueString("Column_1Width", string.Empty).ToLower(); 46 column1width = column1width == "grow" ? "flex-grow-1" : "flex-grow-0"; 47 48 string column2width = Model.Item.GetRawValueString("Column_2Width", string.Empty).ToLower(); 49 column2width = column2width == "grow" ? "flex-grow-1" : "flex-grow-0"; 50 51 string column3width = Model.Item.GetRawValueString("Column_3Width", string.Empty).ToLower(); 52 column3width = column3width == "grow" ? "flex-grow-1" : "flex-grow-0"; 53 54 string column4width = Model.Item.GetRawValueString("Column_4Width", string.Empty).ToLower(); 55 column4width = column4width == "grow" ? "flex-grow-1" : "flex-grow-0"; 56 57 string column5width = Model.Item.GetRawValueString("Column_4Width", string.Empty).ToLower(); 58 column5width = column5width == "grow" ? "flex-grow-1" : "flex-grow-0"; 59 60 string hideOnScroll = Model.Item.GetRawValueString("HideOnScroll", string.Empty).ToLower(); 61 hideOnScroll = hideOnScroll == "hide" ? " js-hide-on-scroll" : string.Empty; 62 63 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 64 string alternativeTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("AlternativeTheme")) ? " theme " + Model.Item.GetRawValueString("AlternativeTheme").Replace(" ", "").Trim().ToLower() : string.Empty; 65 string mainTheme = theme; 66 67 string headerCssClass = "sticky-top"; 68 if (Pageview.Page.PropertyItem != null) { 69 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 70 } 71 headerCssClass = headerCssClass == string.Empty ? "sticky-top" : headerCssClass; 72 headerCssClass = Pageview.IsVisualEditorMode ? string.Empty : headerCssClass; 73 74 string themeSwitchers = string.Empty; 75 string themeAnimated = string.Empty; 76 if (headerCssClass == "fixed-top") { 77 theme = alternativeTheme; 78 themeSwitchers = "data-main-theme=\"" + mainTheme + "\" data-alternative-theme=\"" + alternativeTheme + "\""; 79 themeAnimated = "theme-animated "; 80 } 81 82 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 83 var css = string.Empty; 84 var cssClasses = new List<string> { }; 85 86 foreach (var itemId in decorations) 87 { 88 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 89 item.TryGetValue("Class", out object classes); 90 if (classes is null) 91 { 92 continue; 93 } 94 95 var cssString = (string)classes; 96 if (cssString.StartsWith("[")) 97 { 98 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 99 cssClasses.AddRange(cssArray); 100 } 101 else 102 { 103 cssClasses.Add(cssString.Replace(",", " ")); 104 } 105 } 106 css = string.Join(" ", cssClasses).Trim(); 107 108 var columnContent1 = Model.Column(1).Output(); 109 var columnContent2 = Model.Column(2).Output(); 110 var columnContent3 = Model.Column(3).Output(); 111 var columnContent4 = Model.Column(4).Output(); 112 var columnContent5 = Model.Column(5).Output(); 113 114 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnContent1) || !string.IsNullOrWhiteSpace(columnContent2) || !string.IsNullOrWhiteSpace(columnContent3) || !string.IsNullOrWhiteSpace(columnContent4) || !string.IsNullOrWhiteSpace(columnContent5)) 115 { 116 <div class="@rowHeight @(themeAnimated)@(theme)@(hideOnScroll) @(css) item_@Model.Item.SystemName.ToLower()" @themeSwitchers data-swift-gridrow> 117 <div class="@containerClass"> 118 <div class="d-flex flex-row @rowClass @columnPosition"> 119 <div class="col @column1width"> 120 @columnContent1 121 </div> 122 <div class="col @column2width"> 123 @columnContent2 124 </div> 125 <div class="col @column3width"> 126 @columnContent3 127 </div> 128 <div class="col @column4width"> 129 @columnContent4 130 </div> 131 <div class="col @column5width"> 132 @columnContent5 133 </div> 134 </div> 135 </div> 136 </div> 137 } 138 } 139
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