This is a legitimate expert-level trail, but much of the difficulty can be mitigated by slowing down and picking your line carefully
New 15km bike park in the heart of Pines forrest
Error executing template "Designs/Swift/Paragraph/Swift_Text.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 @functions 4 { 5 private string RenderCustomCSS(IEnumerable<string> decorations) 6 { 7 var cssClasses = new List<string>(); 8 9 foreach (var itemId in decorations) 10 { 11 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 12 item.TryGetValue("Class", out object classes); 13 14 if (classes is null) 15 { 16 continue; 17 } 18 19 var cssString = (string)classes; 20 21 if (cssString.StartsWith("[")) 22 { 23 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 24 cssClasses.AddRange(cssArray); 25 } 26 else 27 { 28 cssClasses.Add(cssString.Replace(",", " ")); 29 } 30 } 31 32 return string.Join(" ", cssClasses).Trim(); 33 } 34 } 35 36 @{ 37 string layout = Model.Item.GetRawValueString("Layout", "text-start"); 38 layout = layout == "alignLeft" ? "align-items-start text-start" : layout; 39 layout = layout == "alignCenter" ? "align-items-center text-center" : layout; 40 layout = layout == "alignRight" ? "align-items-end text-end" : layout; 41 layout = layout == "alignLeftMiddle" ? "align-items-start text-start justify-content-center" : layout; 42 43 string contentPadding = Model.Item.GetRawValueString("ContentPadding", string.Empty); 44 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 45 contentPadding = contentPadding == "small" ? "p-3 p-md-3" : contentPadding; 46 contentPadding = contentPadding == "large" ? "p-5 p-md-5" : contentPadding; 47 48 //Backward compatibility (Vertical align) 49 string verticalAlign = string.Empty; 50 if (!string.IsNullOrEmpty(Model.Item.GetString("verticalAlign"))) 51 { 52 verticalAlign = verticalAlign == "vertical-align-top" ? "justify-content-start" : verticalAlign; 53 verticalAlign = verticalAlign == "vertical-align-center" ? "justify-content-center" : verticalAlign; 54 verticalAlign = verticalAlign == "vertical-align-bottom" ? "justify-content-end" : verticalAlign; 55 } 56 57 string maxWidth = Model.Item.GetRawValueString("TextReadability", "max-width-on"); 58 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth; 59 maxWidth = maxWidth == "max-width-off" ? string.Empty : maxWidth; 60 61 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 62 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 63 string css = RenderCustomCSS(decorations); 64 65 Dynamicweb.Frontend.LinkViewModel link1 = new Dynamicweb.Frontend.LinkViewModel(); 66 Dynamicweb.Frontend.LinkViewModel link2 = new Dynamicweb.Frontend.LinkViewModel(); 67 68 string linkType1 = Model.Item.GetRawValueString("LinkType", "page"); 69 string linkType2 = Model.Item.GetRawValueString("LinkType2", "page2"); 70 71 if (linkType1 == "page" && Model.Item.GetLink("ButtonLink") != null) 72 { 73 link1 = Model.Item.GetLink("ButtonLink"); 74 } 75 76 if (linkType2 == "page2" && Model.Item.GetLink("ButtonLink2") != null) 77 { 78 link2 = Model.Item.GetLink("ButtonLink2"); 79 } 80 81 if (linkType1 == "product-group") 82 { 83 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink"); 84 IList<string> groupIds = new List<string> { }; 85 86 if (selectedGroups != null) 87 { 88 foreach (var fromGroup in selectedGroups) 89 { 90 groupIds.Add(fromGroup.Id); 91 } 92 } 93 94 link1 = new Dynamicweb.Frontend.LinkViewModel() 95 { 96 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds) 97 }; 98 } 99 100 if (linkType2 == "product-group2") 101 { 102 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink2"); 103 IList<string> groupIds = new List<string> { }; 104 105 if (selectedGroups != null) 106 { 107 foreach (var fromGroup in selectedGroups) 108 { 109 groupIds.Add(fromGroup.Id); 110 } 111 } 112 113 link2 = new Dynamicweb.Frontend.LinkViewModel() 114 { 115 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(), 116 IsExternal = false 117 }; 118 } 119 120 if (linkType1 == "product") 121 { 122 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink"); 123 IList<string> productIds = new List<string> { }; 124 125 if (products != null && products.Products.Any()) 126 { 127 foreach (var product in products.Products) 128 { 129 productIds.Add(product.Id); 130 } 131 132 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 133 string productLink = products.Products?.FirstOrDefault()?.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 134 productLink = productIds.Count != 1 ? "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&" + productParameter + "=" + string.Join(",", productIds).Trim() : productLink; 135 136 link1 = new Dynamicweb.Frontend.LinkViewModel() 137 { 138 Url = productLink 139 }; 140 } 141 } 142 143 if (linkType2 == "product2") 144 { 145 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink2"); 146 IList<string> productIds = new List<string> { }; 147 148 if (products != null && products.Products.Any()) 149 { 150 foreach (var product in products.Products) 151 { 152 productIds.Add(product.Id); 153 } 154 155 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 156 string productLink = products.Products?.FirstOrDefault()?.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 157 productLink = productIds.Count != 1 ? "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&" + productParameter + "=" + string.Join(",", productIds).Trim() : productLink; 158 159 link2 = new Dynamicweb.Frontend.LinkViewModel() 160 { 161 Url = productLink, 162 IsExternal = false 163 }; 164 } 165 } 166 } 167 168 <div class="h-100 position-relative d-flex flex-column mb-0-last-child @contentPadding @verticalAlign @(layout)@(theme) @(css) item_@Model.Item.SystemName.ToLower()"> 169 <div id="@Model.ID" class="user-select-none position-absolute top-0" style="scroll-margin-top:var(--header-height,150px)"></div> 170 171 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) && !Model.Item.GetBoolean("HideTitle")) 172 { 173 string titleColor = Model.Item.GetString("TitleColor", "text-inherit"); 174 string titleOpacity = Model.Item.GetString("TitleOpacity", "opacity-100"); 175 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 176 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 177 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {titleColor} {titleOpacity}{maxWidth} mb-3\">"; 178 string headingLevelStop = $"</{headingLevel}>"; 179 180 @headingLevelStart 181 @Model.Item.GetString("Title") 182 @headingLevelStop 183 } 184 185 @if (!string.IsNullOrEmpty(Model.Item.GetString("Lead"))) 186 { 187 string subtitleColor = Model.Item.GetString("SubtitleColor", "text-inherit"); 188 string subtitleOpacity = Model.Item.GetString("SubtitleOpacity", "opacity-100"); 189 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 190 191 <p class="@subtitleFontSize @subtitleColor @subtitleOpacity lead mb-3@(maxWidth)"> 192 @Model.Item.GetString("Lead") 193 </p> 194 } 195 196 @if (!string.IsNullOrEmpty(Model.Item.GetString("Text"))) 197 { 198 string textColor = Model.Item.GetString("TextColor", "text-inherit"); 199 string textOpacity = Model.Item.GetString("TextOpacity", "opacity-100"); 200 201 <div class="mb-0-last-child @textColor @(textOpacity)@(maxWidth)"> 202 @Model.Item.GetString("Text") 203 </div> 204 } 205 206 @if (link1 is object && !string.IsNullOrEmpty(link1.Url) || link2 is object && !string.IsNullOrEmpty(link2.Url)) 207 { 208 string target1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "target=\"_blank\"" : string.Empty; 209 string target2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "target=\"_blank\"" : string.Empty; 210 string rel1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "rel=\"noopener\"" : string.Empty; 211 string rel2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "rel=\"noopener\"" : string.Empty; 212 string buttonLabel1 = Model.Item.GetString("ButtonLabel", string.Empty); 213 string buttonLabel2 = Model.Item.GetString("ButtonLabel2", string.Empty); 214 string buttonStyle1 = Model.Item.GetRawValueString("ButtonStyle", string.Empty); 215 buttonStyle1 = buttonStyle1 == "primary" ? "btn-primary " : buttonStyle1; 216 buttonStyle1 = buttonStyle1 == "secondary" ? "btn-secondary " : buttonStyle1; 217 buttonStyle1 = buttonStyle1 == "link" ? "btn-link" : buttonStyle1; 218 string buttonStyle2 = Model.Item.GetRawValueString("ButtonStyle2", string.Empty); 219 buttonStyle2 = buttonStyle2 == "primary" ? "btn-primary " : buttonStyle2; 220 buttonStyle2 = buttonStyle2 == "secondary" ? "btn-secondary " : buttonStyle2; 221 buttonStyle2 = buttonStyle2 == "link" ? "btn-link" : buttonStyle2; 222 string stretchedLink1 = Model.Item.GetRawValueString("StretchedLink", "column-not-clickable"); 223 string stretchedLink2 = Model.Item.GetRawValueString("StretchedLink2", "column-not-clickable"); 224 string stretchedLinkClass = stretchedLink1 == "column-clickable" && string.IsNullOrEmpty(link2.Url) && string.IsNullOrEmpty(buttonLabel2) ? "stretched-link" : string.Empty; 225 string stretchedLinkClass2 = stretchedLink2 == "column-clickable" && string.IsNullOrEmpty(link1.Url) && string.IsNullOrEmpty(buttonLabel1) ? "stretched-link" : string.Empty; 226 string alignmentClass = string.Empty; 227 228 if (Model.Item.GetString("Layout") == "alignCenter") 229 { 230 alignmentClass = " justify-content-center"; 231 } 232 233 <div class="d-flex flex-wrap gap-3 mt-3@(alignmentClass)"> 234 @if (link1 != null && !string.IsNullOrEmpty(link1.Url)) 235 { 236 if (!string.IsNullOrEmpty(buttonLabel1)) 237 { 238 <a href="@link1.Url" @target1 @rel1 class="text-nowrap btn @(buttonStyle1)@(stretchedLinkClass)">@buttonLabel1</a> 239 } 240 else 241 { 242 <a href="@link1.Url" @target1 @rel1 class="@(stretchedLinkClass)"> 243 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 244 </a> 245 } 246 } 247 248 @if (link2 != null && !string.IsNullOrEmpty(link2.Url)) 249 { 250 if (!string.IsNullOrEmpty(buttonLabel2)) 251 { 252 <a href="@link2.Url" @target2 @rel2 class="text-nowrap btn @(buttonStyle2)@(stretchedLinkClass2)">@buttonLabel2</a> 253 } 254 else 255 { 256 <a href="@link2.Url" @target2 @rel2 class="@(stretchedLinkClass2)"> 257 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 258 </a> 259 } 260 } 261 </div> 262 } 263 </div> 264 265
Ingenting fundet
Beklager, den filterkombination har ingen resultater.
Prøv venligst andre kriterier