Error executing template "Designs/Swift/Paragraph/Swift_ProductCatalogDetailsApp.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2 @using Dynamicweb.Ecommerce.ProductCatalog
3
4 @{
5 //Set default product data for use in Visual Editor
6 if (Pageview.IsVisualEditorMode)
7 {
8 ProductViewModelSettings productSetting = new ProductViewModelSettings
9 {
10 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID,
11 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code,
12 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2,
13 ShopId = Pageview.Area.EcomShopId
14 };
15
16 string selectedDummyProduct = "PROD1";
17 var list = new ProductListViewModel();
18 if (Model.Item.GetValue("DummyProduct") != null)
19 {
20 list = Model.Item.GetValue("DummyProduct") as ProductListViewModel;
21
22 foreach (var product in list.Products)
23 {
24 selectedDummyProduct = product.Id;
25 }
26
27 ProductViewModel dummyProduct = ViewModelFactory.CreateView(productSetting, selectedDummyProduct);
28
29 if (!Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
30 {
31 Dynamicweb.Context.Current.Items.Add("ProductDetails", dummyProduct);
32 }
33 }
34 else
35 {
36 <div class="alert alert-danger" role="alert">
37 <span>@Translate("Please select a Dummy product on this paragraph")</span>
38 </div>
39 }
40 }
41 else if (!Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
42 {
43 ProductViewModel dummyProduct = new ProductViewModel();
44 Dynamicweb.Context.Current.Items.Add("ProductDetails", dummyProduct);
45 }
46 }
47
48 @if (Pageview.IsVisualEditorMode)
49 {
50 <div class="alert alert-info" role="alert">
51 <span>@Translate("Product catalog App: Edit this column to configure. (Product catalog app must be attached this paragraph)")</span>
52 </div>
53 }
54
55 <div class="item_@Model.Item.SystemName.ToLower()">
56 @Model.GetModuleOutput()
57 </div>
58
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/2Columns_8-4.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.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 //Mobile
9 if (spaceBetweenRowsMobile == "auto")
10 {
11 spaceBetweenRowsMobile = spaceBetweenRows;
12 }
13 if (spaceBetweenRowsMobile == "none")
14 {
15 sectionClass = "py-0";
16 }
17 if (spaceBetweenRowsMobile == "spacing")
18 {
19 sectionClass = "py-3";
20 }
21 if (spaceBetweenRowsMobile == "spacing-large")
22 {
23 sectionClass = "py-5";
24 }
25 if (spaceBetweenRowsMobile == "spacing-small-top")
26 {
27 sectionClass = "pt-3";
28 }
29 if (spaceBetweenRowsMobile == "spacing-small-bottom")
30 {
31 sectionClass = "pb-3";
32 }
33 if (spaceBetweenRowsMobile == "spacing-top")
34 {
35 sectionClass = "pt-5";
36 }
37 if (spaceBetweenRowsMobile == "spacing-bottom")
38 {
39 sectionClass = "pb-5";
40 }
41 //Desktop
42 if (spaceBetweenRows == "none")
43 {
44 sectionClass += " py-lg-0";
45 }
46 if (spaceBetweenRows == "spacing")
47 {
48 sectionClass += " py-lg-3";
49 }
50 if (spaceBetweenRows == "spacing-large") {
51 sectionClass += " py-lg-6";
52 }
53 if (spaceBetweenRows == "spacing-small-top")
54 {
55 sectionClass += " pt-lg-3 pb-lg-0 ";
56 }
57 if (spaceBetweenRows == "spacing-small-bottom")
58 {
59 sectionClass += " pb-lg-3 pt-lg-0";
60 }
61 if (spaceBetweenRows == "spacing-top") {
62 sectionClass += " pt-lg-6 pb-lg-0 ";
63 }
64 if (spaceBetweenRows == "spacing-bottom") {
65 sectionClass += " pb-lg-6 pt-lg-0";
66 }
67
68 string containerClass = "container-xl";
69 string width = Model.Item.GetRawValueString("Width", "container-xl");
70 if (width == "none")
71 {
72 containerClass = string.Empty;
73 }
74 if (width == "stretch")
75 {
76 containerClass = "container-fluid";
77 }
78 if (width == "compressed")
79 {
80 containerClass = " container-compressed";
81 }
82
83 string rowClass = string.Empty;
84 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", string.Empty).ToLower();
85 string spaceBetweenColumnsMobile = Model.Item.GetRawValueString("SpaceBetweenColumnsMobile", string.Empty).ToLower();
86 //Mobile
87 if (spaceBetweenColumnsMobile == "auto")
88 {
89 spaceBetweenColumnsMobile = spaceBetweenColumns;
90 }
91 if (spaceBetweenColumnsMobile == "stick")
92 {
93 rowClass = " gap-0";
94 }
95 if (spaceBetweenColumnsMobile == "spacing-medium")
96 {
97 rowClass = " gap-4";
98 }
99 if (spaceBetweenColumnsMobile == "spacing-large")
100 {
101 rowClass = " gap-5";
102 }
103 //Desktop
104 if (spaceBetweenColumns == "stick")
105 {
106 rowClass += " gap-lg-0";
107 }
108 if (spaceBetweenColumns == "spacing-medium")
109 {
110 rowClass += " gap-lg-4";
111 }
112 if (spaceBetweenColumns == "spacing-large")
113 {
114 rowClass += " gap-lg-5";
115 }
116
117 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
118
119 string animationOnScrollCol1 = Model.Item.GetRawValueString("AnimationOnScrollCol1", "no-animation");
120 animationOnScrollCol1 = animationOnScrollCol1 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol1 + "'" : "";
121 string animationOnScrollCol2 = Model.Item.GetRawValueString("AnimationOnScrollCol2", "no-animation");
122 animationOnScrollCol2 = animationOnScrollCol2 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol2 + "'" : "";
123
124 string hideOverflow = " overflow-hidden";
125 hideOverflow =
126 animationOnScrollCol1 != "" ||
127 animationOnScrollCol2 != ""
128 ? hideOverflow : "";
129
130 Dynamicweb.Frontend.FileViewModel backgroundImage = Model.Item.GetFile("BackgroundImage");
131 string backgroundImagePath = backgroundImage?.Path ?? string.Empty;
132 string imagePath = $"/Admin/Public/GetImage.ashx?image={backgroundImagePath}&width=960&format=webp";
133 backgroundImagePath = Dynamicweb.Core.Encoders.HtmlEncoder.UrlPathEncode(backgroundImagePath);
134 string backgroundRepeat = Model.Item.GetRawValueString("BackgroundImageRepeat", "no-repeat");
135 string backgroundImageSize = Model.Item.GetRawValueString("BackgroundImageSize", "initial");
136 int xPos = backgroundImage?.FocalPositionFromLeft ?? 50;
137 int yPos = backgroundImage?.FocalPositionFromTop ?? 50;
138 string cssPosition = $"{xPos}% {yPos}%";
139 string gradient = Model.Item.GetRawValueString("Gradient", string.Empty);
140 string gradientOpacity = Model.Item.GetRawValueString("GradientOpacity", "0.00");
141 string gradientString = "linear-gradient(" + gradient + "deg," + "rgba(var(--swift-foreground-color-rgb)," + gradientOpacity + "), rgba(var(--swift-background-color-rgb)," + gradientOpacity + "))";
142 string backgroundImageString = "url(" + backgroundImagePath + ")";
143 string backgroundImagePositionString = "background-position:" + cssPosition + ";";
144 string backgroundRepeatString = "background-repeat:" + backgroundRepeat + ";";
145 string backgroundImageSizeString = "background-size:" + backgroundImageSize + ";";
146 string styleString = string.Empty;
147
148 @* Only gradient *@
149
150 if (!string.IsNullOrEmpty(gradient) && string.IsNullOrEmpty(backgroundImagePath) && gradientOpacity != ("0.00"))
151 {
152 styleString += "style=\"background-image:" + gradientString + ";\"";
153 }
154
155 @* Only background image *@
156
157 else if (string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
158 {
159 styleString += "style=\"background-image:" + backgroundImageString + "," + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
160 }
161
162 @* Gradient and background image *@
163
164 else if (!string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
165 {
166 styleString += "style=\"background-image:" + gradientString + "," + backgroundImageString + ";" + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
167 }
168
169 int mobileColumnSize = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileColumnBehaviour", "1"));
170 int mobileOrderFirst = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileOrderFirst", "1"));
171
172 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(Model.Column(1).Output()) || !string.IsNullOrWhiteSpace(Model.Column(2).Output()))
173 {
174 <div class="@(sectionClass)@(theme) item_@Model.Item.SystemName.ToLower()" @styleString>
175 <div class="@containerClass@(hideOverflow)">
176 <div class="grid grid-@(mobileColumnSize) grid-lg-3@(rowClass)">
177 <div class="g-col g-col-lg-2 @(Model.Column(1).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="8" @animationOnScrollCol2 style="--bs-columns:12">
178 @Model.Column(1).Output()
179 </div>
180 <div class="g-col @(Model.Column(2).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="4" @animationOnScrollCol1 style="--bs-columns:12">
181 @Model.Column(2).Output()
182 </div>
183 </div>
184 </div>
185 </div>
186 }
187 }
188
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/2Columns_8-4.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.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 //Mobile
9 if (spaceBetweenRowsMobile == "auto")
10 {
11 spaceBetweenRowsMobile = spaceBetweenRows;
12 }
13 if (spaceBetweenRowsMobile == "none")
14 {
15 sectionClass = "py-0";
16 }
17 if (spaceBetweenRowsMobile == "spacing")
18 {
19 sectionClass = "py-3";
20 }
21 if (spaceBetweenRowsMobile == "spacing-large")
22 {
23 sectionClass = "py-5";
24 }
25 if (spaceBetweenRowsMobile == "spacing-small-top")
26 {
27 sectionClass = "pt-3";
28 }
29 if (spaceBetweenRowsMobile == "spacing-small-bottom")
30 {
31 sectionClass = "pb-3";
32 }
33 if (spaceBetweenRowsMobile == "spacing-top")
34 {
35 sectionClass = "pt-5";
36 }
37 if (spaceBetweenRowsMobile == "spacing-bottom")
38 {
39 sectionClass = "pb-5";
40 }
41 //Desktop
42 if (spaceBetweenRows == "none")
43 {
44 sectionClass += " py-lg-0";
45 }
46 if (spaceBetweenRows == "spacing")
47 {
48 sectionClass += " py-lg-3";
49 }
50 if (spaceBetweenRows == "spacing-large") {
51 sectionClass += " py-lg-6";
52 }
53 if (spaceBetweenRows == "spacing-small-top")
54 {
55 sectionClass += " pt-lg-3 pb-lg-0 ";
56 }
57 if (spaceBetweenRows == "spacing-small-bottom")
58 {
59 sectionClass += " pb-lg-3 pt-lg-0";
60 }
61 if (spaceBetweenRows == "spacing-top") {
62 sectionClass += " pt-lg-6 pb-lg-0 ";
63 }
64 if (spaceBetweenRows == "spacing-bottom") {
65 sectionClass += " pb-lg-6 pt-lg-0";
66 }
67
68 string containerClass = "container-xl";
69 string width = Model.Item.GetRawValueString("Width", "container-xl");
70 if (width == "none")
71 {
72 containerClass = string.Empty;
73 }
74 if (width == "stretch")
75 {
76 containerClass = "container-fluid";
77 }
78 if (width == "compressed")
79 {
80 containerClass = " container-compressed";
81 }
82
83 string rowClass = string.Empty;
84 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", string.Empty).ToLower();
85 string spaceBetweenColumnsMobile = Model.Item.GetRawValueString("SpaceBetweenColumnsMobile", string.Empty).ToLower();
86 //Mobile
87 if (spaceBetweenColumnsMobile == "auto")
88 {
89 spaceBetweenColumnsMobile = spaceBetweenColumns;
90 }
91 if (spaceBetweenColumnsMobile == "stick")
92 {
93 rowClass = " gap-0";
94 }
95 if (spaceBetweenColumnsMobile == "spacing-medium")
96 {
97 rowClass = " gap-4";
98 }
99 if (spaceBetweenColumnsMobile == "spacing-large")
100 {
101 rowClass = " gap-5";
102 }
103 //Desktop
104 if (spaceBetweenColumns == "stick")
105 {
106 rowClass += " gap-lg-0";
107 }
108 if (spaceBetweenColumns == "spacing-medium")
109 {
110 rowClass += " gap-lg-4";
111 }
112 if (spaceBetweenColumns == "spacing-large")
113 {
114 rowClass += " gap-lg-5";
115 }
116
117 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
118
119 string animationOnScrollCol1 = Model.Item.GetRawValueString("AnimationOnScrollCol1", "no-animation");
120 animationOnScrollCol1 = animationOnScrollCol1 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol1 + "'" : "";
121 string animationOnScrollCol2 = Model.Item.GetRawValueString("AnimationOnScrollCol2", "no-animation");
122 animationOnScrollCol2 = animationOnScrollCol2 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol2 + "'" : "";
123
124 string hideOverflow = " overflow-hidden";
125 hideOverflow =
126 animationOnScrollCol1 != "" ||
127 animationOnScrollCol2 != ""
128 ? hideOverflow : "";
129
130 Dynamicweb.Frontend.FileViewModel backgroundImage = Model.Item.GetFile("BackgroundImage");
131 string backgroundImagePath = backgroundImage?.Path ?? string.Empty;
132 string imagePath = $"/Admin/Public/GetImage.ashx?image={backgroundImagePath}&width=960&format=webp";
133 backgroundImagePath = Dynamicweb.Core.Encoders.HtmlEncoder.UrlPathEncode(backgroundImagePath);
134 string backgroundRepeat = Model.Item.GetRawValueString("BackgroundImageRepeat", "no-repeat");
135 string backgroundImageSize = Model.Item.GetRawValueString("BackgroundImageSize", "initial");
136 int xPos = backgroundImage?.FocalPositionFromLeft ?? 50;
137 int yPos = backgroundImage?.FocalPositionFromTop ?? 50;
138 string cssPosition = $"{xPos}% {yPos}%";
139 string gradient = Model.Item.GetRawValueString("Gradient", string.Empty);
140 string gradientOpacity = Model.Item.GetRawValueString("GradientOpacity", "0.00");
141 string gradientString = "linear-gradient(" + gradient + "deg," + "rgba(var(--swift-foreground-color-rgb)," + gradientOpacity + "), rgba(var(--swift-background-color-rgb)," + gradientOpacity + "))";
142 string backgroundImageString = "url(" + backgroundImagePath + ")";
143 string backgroundImagePositionString = "background-position:" + cssPosition + ";";
144 string backgroundRepeatString = "background-repeat:" + backgroundRepeat + ";";
145 string backgroundImageSizeString = "background-size:" + backgroundImageSize + ";";
146 string styleString = string.Empty;
147
148 @* Only gradient *@
149
150 if (!string.IsNullOrEmpty(gradient) && string.IsNullOrEmpty(backgroundImagePath) && gradientOpacity != ("0.00"))
151 {
152 styleString += "style=\"background-image:" + gradientString + ";\"";
153 }
154
155 @* Only background image *@
156
157 else if (string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
158 {
159 styleString += "style=\"background-image:" + backgroundImageString + "," + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
160 }
161
162 @* Gradient and background image *@
163
164 else if (!string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
165 {
166 styleString += "style=\"background-image:" + gradientString + "," + backgroundImageString + ";" + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
167 }
168
169 int mobileColumnSize = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileColumnBehaviour", "1"));
170 int mobileOrderFirst = Dynamicweb.Core.Converter.ToInt32(Model.Item.GetRawValueString("MobileOrderFirst", "1"));
171
172 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(Model.Column(1).Output()) || !string.IsNullOrWhiteSpace(Model.Column(2).Output()))
173 {
174 <div class="@(sectionClass)@(theme) item_@Model.Item.SystemName.ToLower()" @styleString>
175 <div class="@containerClass@(hideOverflow)">
176 <div class="grid grid-@(mobileColumnSize) grid-lg-3@(rowClass)">
177 <div class="g-col g-col-lg-2 @(Model.Column(1).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="8" @animationOnScrollCol2 style="--bs-columns:12">
178 @Model.Column(1).Output()
179 </div>
180 <div class="g-col @(Model.Column(2).ColumnNumber == mobileOrderFirst ? "order-first order-lg-0" : string.Empty)" data-col-size="4" @animationOnScrollCol1 style="--bs-columns:12">
181 @Model.Column(2).Output()
182 </div>
183 </div>
184 </div>
185 </div>
186 }
187 }
188
Error executing template "Designs/Swift/Paragraph/Swift_RelatedProducts.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2 @using Dynamicweb.Core
3 @using Dynamicweb.Ecommerce.ProductCatalog
4
5 @{
6 bool productViewModelFound = false;
7 ProductViewModel product = new ProductViewModel();
8
9 ProductViewModelSettings productSetting = new ProductViewModelSettings
10 {
11 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID,
12 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code,
13 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2,
14 ShopId = Pageview.Area.EcomShopId
15 };
16
17 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
18 {
19 productViewModelFound = true;
20 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
21 }
22 if (Pageview.IsVisualEditorMode && !productViewModelFound)
23 {
24 if (Pageview.Item["DummyProduct"] != null)
25 {
26 productViewModelFound = true;
27 string dummyProductId = "";
28 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page);
29 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel();
30 if (productList.Products != null)
31 {
32 foreach (var p in productList.Products) { dummyProductId = p.Id; }
33 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel();
34 product = dummyProduct;
35 }
36 else
37 {
38 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id);
39 }
40 }
41 else if (Pageview.Item["DummyProduct"] == null)
42 {
43 productViewModelFound = true;
44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id);
45 }
46 }
47
48 string title = Model?.Item?.GetString("Title") != null ? Model.Item.GetString("Title") : Translate("Products");
49
50 string campaignValues = Model.Item.GetRawValueString("CampaignBadges", string.Empty);
51
52 //Styling
53 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3");
54 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5");
55 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", "");
56 buttonStyle = buttonStyle == "primary" ? " btn-primary" : buttonStyle;
57 buttonStyle = buttonStyle == "secondary" ? " btn-secondary" : buttonStyle;
58 buttonStyle = buttonStyle == "link" ? " btn-link" : buttonStyle;
59 string maxWidth = Model.Item.GetRawValueString("TextReadability", "");
60 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth;
61 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth;
62
63 string generalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("GeneralTheme")) ? " theme " + Model.Item.GetRawValueString("GeneralTheme").Replace(" ", "").Trim().ToLower() : "";
64 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
65 string imageTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : "";
66
67 //Link generation
68 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : "";
69 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : "";
70 pageId = pageId == "" ? servicePageByNavigationTag : pageId;
71
72 string url = "/Default.aspx?ID=" + pageId;
73 if (!url.Contains("LayoutTemplate"))
74 {
75 url += url.Contains("?") ? "&LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml" : "?LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml";
76 }
77 if (Pageview.IsVisualEditorMode)
78 {
79 url += "&VisualEdit=True";
80 }
81
82 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled;
83 if (isLazyLoadingForProductInfoEnabled)
84 {
85 url += "&getproductinfo=true";
86 }
87
88 //Source type
89 string sourceType = Model.Item.GetRawValueString("RelationType", "trending");
90 IList<string> relateFromGroupIds = new List<string> { };
91 IList<string> relateFromProductIds = new List<string> { };
92
93 //--- VARIANTS ---
94 ProductListViewModel productsToRelateToVariants = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateToVariants");
95 if (productsToRelateToVariants != null && sourceType == "variants")
96 {
97 foreach (var productSelection in productsToRelateToVariants.Products)
98 {
99 relateFromProductIds.Add(productSelection.Id);
100 }
101 }
102
103 //--- MOST SOLD ---
104 IList<ProductGroupViewModel> groupsToRelateToMostSold = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToMostSold");
105 if (groupsToRelateToMostSold != null && sourceType == "most-sold")
106 {
107 foreach (var fromGroup in groupsToRelateToMostSold)
108 {
109 relateFromGroupIds.Add(fromGroup.Id);
110 }
111 }
112
113 //--- TRENDING ---
114 IList<ProductGroupViewModel> groupsToRelateToTrending = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToTrending");
115 if (groupsToRelateToTrending != null && sourceType == "trending")
116 {
117 foreach (var fromGroup in groupsToRelateToTrending)
118 {
119 relateFromGroupIds.Add(fromGroup.Id);
120 }
121 }
122
123 //--- LATEST ---
124 IList<ProductGroupViewModel> groupsToRelateToLatest = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToLatest");
125 if (groupsToRelateToLatest != null && sourceType == "latest")
126 {
127 foreach (var fromGroup in groupsToRelateToLatest)
128 {
129 relateFromGroupIds.Add(fromGroup.Id);
130 }
131 }
132
133 //--- FREQUENTLY BOUGHT ---
134 ProductListViewModel productsToRelateTo = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo");
135 if (productsToRelateTo != null && sourceType == "frequently")
136 {
137 foreach (var fromProduct in productsToRelateTo.Products)
138 {
139 relateFromProductIds.Add(fromProduct.Id);
140 }
141 }
142
143 //--- SELECTED PRODUCTS ---
144 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("Products");
145 if (products != null && sourceType == "selected")
146 {
147 foreach (var productSelection in products.Products)
148 {
149 relateFromProductIds.Add(productSelection.Id);
150 }
151 }
152
153 //--- RELATED PRODUCTS ---
154 if (sourceType == "related-products")
155 {
156 ProductListViewModel selectedRelationProduct = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo2");
157 if (selectedRelationProduct?.Products != null)
158 {
159 if (selectedRelationProduct.Products.Count > 0)
160 {
161 int productCount = 0;
162 foreach (var selectedProduct in selectedRelationProduct.Products)
163 {
164 if (productCount == 0)
165 {
166 product = selectedProduct;
167 productCount++;
168 }
169 }
170 }
171 }
172
173 if (product?.RelatedGroups != null)
174 {
175 foreach (var group in product.RelatedGroups)
176 {
177 foreach (var relatedProduct in group.Products)
178 {
179 relateFromProductIds.Add(relatedProduct.ProductId);
180 }
181 }
182 }
183 }
184
185 //Create group id collection and products id collection strings
186 string groupIds = productViewModelFound ? product.PrimaryOrDefaultGroup.Id : string.Join(",", relateFromGroupIds);
187 string productIds = productViewModelFound && relateFromProductIds.Count == 0 ? product.Id : string.Join(",", relateFromProductIds);
188
189 //Set the parameters to the url
190 string linkParameters = "";
191 linkParameters += sourceType != "related-products" ? "&GroupId=" + groupIds : "";
192 linkParameters += !string.IsNullOrEmpty(productIds) ? "&MainProductId=" + productIds : "";
193 var productListPageId = GetPageIdByNavigationTag("Shop");
194 string link = "/Default.aspx?ID=" + productListPageId + linkParameters;
195
196 // Slider settings (documentation: swiffyslider.com/configuration)
197 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}";
198 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}";
199 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", "slider-indicators-hidden")}";
200 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty;
201
202 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty;
203 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty;
204 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty;
205 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty;
206 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty;
207 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty;
208 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty;
209 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty;
210 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty;
211 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty;
212 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty;
213
214 bool productsFound = true;
215 if (string.IsNullOrEmpty(groupIds) && string.IsNullOrEmpty(productIds))
216 {
217 if (Pageview.IsVisualEditorMode)
218 {
219 productIds = product.Id;
220 sourceType = "selected";
221 }
222 else
223 {
224 productsFound = false;
225 }
226 }
227 }
228
229 @*Container element for the request*@
230 @if (productsFound)
231 {
232 <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()">
233 <input type="hidden" name="ModelID" value="@Model.ID" />
234
235 @*--- SLIDER SETTINGS ---*@
236 <input type="hidden" name="NavigationStyle" value="@navigationStyle" />
237 <input type="hidden" name="NavigationPlacement" value="@navigationPlacement" />
238 <input type="hidden" name="IndicatorStyle" value="@indicatorStyle" />
239 <input type="hidden" name="RevealSlides" value="@revealSlides" />
240
241 <input type="hidden" name="NavigationAlwaysVisible" value="@(navigationAlwaysVisible)" />
242 <input type="hidden" name="NavigationVisibleOnTouch" value="@(navigationVisibleOnTouch)" />
243 <input type="hidden" name="NavigationShowScrollbar" value="@(navigationShowScrollbar)" />
244 <input type="hidden" name="NavigationSmall" value="@(navigationSmall)" />
245 <input type="hidden" name="NavigationInvertColors" value="@(navigationInvertColors)" />
246 <input type="hidden" name="NavigationNoLoop" value="@(navigationNoLoop)" />
247 <input type="hidden" name="NavigationSlideEntirePage" value="@(navigationSlideEntirePage)" />
248 <input type="hidden" name="IndicatorsOutsideSlider" value="@(indicatorsOutsideSlider)" />
249 <input type="hidden" name="IndicatorsHighlightActive" value="@(indicatorsHighlightActive)" />
250 <input type="hidden" name="IndicatorsInvertColors" value="@(indicatorsInvertColors)" />
251 <input type="hidden" name="IndicatorsVisibleOnSmallDevices" value="@(indicatorsVisibleOnSmallDevices)" />
252
253 @*--- VARIANTS ---*@
254 @if (sourceType == "variants")
255 {
256 <input type="hidden" name="isVariant" value="true" />
257 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
258 }
259
260 @*--- MOST SOLD ---*@
261 @if (sourceType == "most-sold")
262 {
263 <input type="hidden" name="SortBy" value="OrderCount" />
264 if (groupIds != "")
265 {
266 <input type="hidden" name="GroupId" value="@groupIds" />
267 }
268 }
269
270 @*--- TRENDING ---*@
271 @if (sourceType == "trending")
272 {
273 <input type="hidden" name="SortBy" value="OrderCountGrowth" />
274 if (groupIds != "")
275 {
276 <input type="hidden" name="GroupId" value="@groupIds" />
277 }
278 }
279
280 @*--- FREQUENTLY BOUGHT ---*@
281 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds))
282 {
283 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]" />
284 }
285
286 @*--- LATEST ---*@
287 @if (sourceType == "latest")
288 {
289 <input type="hidden" name="SortBy" value="Created" />
290 <input type="hidden" name="GroupId" value="@groupIds" />
291 }
292
293 @*--- SELECTED PRODUCTS ---*@
294 @if (sourceType == "selected")
295 {
296 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
297 }
298
299 @*--- RELATED PRODUCTS ---*@
300 @if (sourceType == "related-products")
301 {
302 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
303 }
304
305 @* General parameters *@
306 <input type="hidden" name="Link" value="@link" />
307 <input type="hidden" name="HideTitle" value="@Model.Item.GetString("HideTitle")" />
308 <input type="hidden" name="SortOrder" value="DESC" />
309 @if (Model.Item.GetInt32("ProductsCount") != 0)
310 {
311 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")" />
312 }
313 <input type="hidden" name="HeadingTitle" id="RelatedProductsTitle_@Model.ID" value="@title" />
314 @if (!string.IsNullOrEmpty(Model.Item.GetString("Subtitle")))
315 {
316 <input type="hidden" name="Subtitle" value="@Model.Item.GetString("Subtitle")" />
317 }
318 @if (!string.IsNullOrEmpty(Model.Item.GetString("LinkText")))
319 {
320 <input type="hidden" name="LinkText" value="@Model.Item.GetString("LinkText")" />
321 }
322 @if (!string.IsNullOrEmpty(Model.Item.GetString("ImageAspectRatio")))
323 {
324 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", "");
325 ratio = ratio != "0" ? ratio : "";
326 <input type="hidden" name="ImageAspectRatio" value="@ratio" />
327 }
328 @if (!string.IsNullOrEmpty(Model.Item.GetString("Layout")))
329 {
330 <input type="hidden" name="Layout" value="@Model.Item.GetRawValueString("Layout")" />
331 }
332 @if (titleFontSize != "")
333 {
334 <input type="hidden" name="TitleFontSize" value="@titleFontSize" />
335 }
336 @if (subtitleFontSize != "")
337 {
338 <input type="hidden" name="SubtitleFontSize" value="@subtitleFontSize" />
339 }
340 @if (buttonStyle != "")
341 {
342 <input type="hidden" name="ButtonStyle" value="@buttonStyle" />
343 }
344 @if (generalTheme != "")
345 {
346 <input type="hidden" name="GeneralTheme" value="@generalTheme" />
347 }
348 @if (theme != "")
349 {
350 <input type="hidden" name="Theme" value="@theme" />
351 }
352 @if (imageTheme != "")
353 {
354 <input type="hidden" name="ImageTheme" value="@imageTheme" />
355 }
356 @if (!string.IsNullOrEmpty(Model.Item.GetString("ContentPadding")))
357 {
358 string contentPadding = Model.Item.GetRawValueString("ContentPadding");
359 <input type="hidden" name="ContentPadding" value="@contentPadding" />
360 }
361 <input type="hidden" name="TextReadability" value="@maxWidth" />
362 <input type="hidden" name="ParentColumnSize" id="ParentColumnSize_@Model.ID" value="12" />
363
364 <input type="hidden" name="SaleBadgeType" value="@Model.Item.GetRawValue("SaleBadgeType")" />
365 <input type="hidden" name="SaleBadgeCssClassName" value="@Model.Item.GetRawValue("SaleBadgeDesign")" />
366 <input type="hidden" name="NewBadgeCssClassName" value="@Model.Item.GetRawValue("NewBadgeDesign")" />
367 <input type="hidden" name="NewPublicationDays" value="@Model.Item.GetInt32("NewPublicationDays")" />
368
369 @if (campaignValues != "")
370 {
371 <input type="hidden" name="CampaignBadgesValues" value="@campaignValues" />
372 }
373 </form>
374
375 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script>
376 <script type="module">
377 swift.AssetLoader.Load('Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css');
378 </script>
379
380 if (sourceType != "related-products")
381 {
382 <div class="w-100 h-100">
383 <div id="RelatedProducts_@Model.ID" class="h-100" style="min-height: 345px"></div>
384 </div>
385 }
386 else if (product?.RelatedGroups != null)
387 {
388 @* Create multiple slider containers, if type is Product relation *@
389 <div class="grid w-100 h-100@(generalTheme)" style="grid-row-gap: 4rem">
390 @foreach (var group in product.RelatedGroups)
391 {
392 <div id="RelatedProducts_@(Model.ID)_@group.Id" class="g-col-12 h-100" style="min-height: 345px"></div>
393 }
394 </div>
395 }
396
397 @* Initialize *@
398 if (sourceType != "related-products")
399 {
400 <script type="module">
401 if (document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]")) {
402 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]").getAttribute("data-col-size");
403 }
404 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID"));
405 </script>
406 }
407 else if (product?.RelatedGroups != null)
408 {
409 @* Create multiple sliders, if type is Product relation *@
410 foreach (var group in product.RelatedGroups)
411 {
412 IList<string> fromProductIds = new List<string> { };
413
414 foreach (var relatedProduct in group.Products)
415 {
416 fromProductIds.Add(relatedProduct.ProductId);
417 }
418 <script type="module">
419 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@(Model.ID)_@group.Id").closest("[data-col-size]").getAttribute("data-col-size");
420 document.querySelector("#MainProductID_@Model.ID").value = "@string.Join(",", fromProductIds)";
421 document.querySelector("#RelatedProductsTitle_@Model.ID").value = "@group.Name";
422 document.querySelector("#RelatedProductsForm_@Model.ID").setAttribute("data-response-target-element", "RelatedProducts_@(Model.ID)_@group.Id");
423
424 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID"));
425 </script>
426 }
427 }
428 }
429
Error executing template "Designs/Swift/Paragraph/Swift_RelatedProducts.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2 @using Dynamicweb.Core
3 @using Dynamicweb.Ecommerce.ProductCatalog
4
5 @{
6 bool productViewModelFound = false;
7 ProductViewModel product = new ProductViewModel();
8
9 ProductViewModelSettings productSetting = new ProductViewModelSettings
10 {
11 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID,
12 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code,
13 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2,
14 ShopId = Pageview.Area.EcomShopId
15 };
16
17 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
18 {
19 productViewModelFound = true;
20 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
21 }
22 if (Pageview.IsVisualEditorMode && !productViewModelFound)
23 {
24 if (Pageview.Item["DummyProduct"] != null)
25 {
26 productViewModelFound = true;
27 string dummyProductId = "";
28 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page);
29 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel();
30 if (productList.Products != null)
31 {
32 foreach (var p in productList.Products) { dummyProductId = p.Id; }
33 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel();
34 product = dummyProduct;
35 }
36 else
37 {
38 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id);
39 }
40 }
41 else if (Pageview.Item["DummyProduct"] == null)
42 {
43 productViewModelFound = true;
44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id);
45 }
46 }
47
48 string title = Model?.Item?.GetString("Title") != null ? Model.Item.GetString("Title") : Translate("Products");
49
50 string campaignValues = Model.Item.GetRawValueString("CampaignBadges", string.Empty);
51
52 //Styling
53 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3");
54 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5");
55 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", "");
56 buttonStyle = buttonStyle == "primary" ? " btn-primary" : buttonStyle;
57 buttonStyle = buttonStyle == "secondary" ? " btn-secondary" : buttonStyle;
58 buttonStyle = buttonStyle == "link" ? " btn-link" : buttonStyle;
59 string maxWidth = Model.Item.GetRawValueString("TextReadability", "");
60 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth;
61 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth;
62
63 string generalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("GeneralTheme")) ? " theme " + Model.Item.GetRawValueString("GeneralTheme").Replace(" ", "").Trim().ToLower() : "";
64 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
65 string imageTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : "";
66
67 //Link generation
68 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : "";
69 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : "";
70 pageId = pageId == "" ? servicePageByNavigationTag : pageId;
71
72 string url = "/Default.aspx?ID=" + pageId;
73 if (!url.Contains("LayoutTemplate"))
74 {
75 url += url.Contains("?") ? "&LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml" : "?LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml";
76 }
77 if (Pageview.IsVisualEditorMode)
78 {
79 url += "&VisualEdit=True";
80 }
81
82 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled;
83 if (isLazyLoadingForProductInfoEnabled)
84 {
85 url += "&getproductinfo=true";
86 }
87
88 //Source type
89 string sourceType = Model.Item.GetRawValueString("RelationType", "trending");
90 IList<string> relateFromGroupIds = new List<string> { };
91 IList<string> relateFromProductIds = new List<string> { };
92
93 //--- VARIANTS ---
94 ProductListViewModel productsToRelateToVariants = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateToVariants");
95 if (productsToRelateToVariants != null && sourceType == "variants")
96 {
97 foreach (var productSelection in productsToRelateToVariants.Products)
98 {
99 relateFromProductIds.Add(productSelection.Id);
100 }
101 }
102
103 //--- MOST SOLD ---
104 IList<ProductGroupViewModel> groupsToRelateToMostSold = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToMostSold");
105 if (groupsToRelateToMostSold != null && sourceType == "most-sold")
106 {
107 foreach (var fromGroup in groupsToRelateToMostSold)
108 {
109 relateFromGroupIds.Add(fromGroup.Id);
110 }
111 }
112
113 //--- TRENDING ---
114 IList<ProductGroupViewModel> groupsToRelateToTrending = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToTrending");
115 if (groupsToRelateToTrending != null && sourceType == "trending")
116 {
117 foreach (var fromGroup in groupsToRelateToTrending)
118 {
119 relateFromGroupIds.Add(fromGroup.Id);
120 }
121 }
122
123 //--- LATEST ---
124 IList<ProductGroupViewModel> groupsToRelateToLatest = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToLatest");
125 if (groupsToRelateToLatest != null && sourceType == "latest")
126 {
127 foreach (var fromGroup in groupsToRelateToLatest)
128 {
129 relateFromGroupIds.Add(fromGroup.Id);
130 }
131 }
132
133 //--- FREQUENTLY BOUGHT ---
134 ProductListViewModel productsToRelateTo = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo");
135 if (productsToRelateTo != null && sourceType == "frequently")
136 {
137 foreach (var fromProduct in productsToRelateTo.Products)
138 {
139 relateFromProductIds.Add(fromProduct.Id);
140 }
141 }
142
143 //--- SELECTED PRODUCTS ---
144 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("Products");
145 if (products != null && sourceType == "selected")
146 {
147 foreach (var productSelection in products.Products)
148 {
149 relateFromProductIds.Add(productSelection.Id);
150 }
151 }
152
153 //--- RELATED PRODUCTS ---
154 if (sourceType == "related-products")
155 {
156 ProductListViewModel selectedRelationProduct = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo2");
157 if (selectedRelationProduct?.Products != null)
158 {
159 if (selectedRelationProduct.Products.Count > 0)
160 {
161 int productCount = 0;
162 foreach (var selectedProduct in selectedRelationProduct.Products)
163 {
164 if (productCount == 0)
165 {
166 product = selectedProduct;
167 productCount++;
168 }
169 }
170 }
171 }
172
173 if (product?.RelatedGroups != null)
174 {
175 foreach (var group in product.RelatedGroups)
176 {
177 foreach (var relatedProduct in group.Products)
178 {
179 relateFromProductIds.Add(relatedProduct.ProductId);
180 }
181 }
182 }
183 }
184
185 //Create group id collection and products id collection strings
186 string groupIds = productViewModelFound ? product.PrimaryOrDefaultGroup.Id : string.Join(",", relateFromGroupIds);
187 string productIds = productViewModelFound && relateFromProductIds.Count == 0 ? product.Id : string.Join(",", relateFromProductIds);
188
189 //Set the parameters to the url
190 string linkParameters = "";
191 linkParameters += sourceType != "related-products" ? "&GroupId=" + groupIds : "";
192 linkParameters += !string.IsNullOrEmpty(productIds) ? "&MainProductId=" + productIds : "";
193 var productListPageId = GetPageIdByNavigationTag("Shop");
194 string link = "/Default.aspx?ID=" + productListPageId + linkParameters;
195
196 // Slider settings (documentation: swiffyslider.com/configuration)
197 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}";
198 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}";
199 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", "slider-indicators-hidden")}";
200 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty;
201
202 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty;
203 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty;
204 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty;
205 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty;
206 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty;
207 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty;
208 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty;
209 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty;
210 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty;
211 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty;
212 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty;
213
214 bool productsFound = true;
215 if (string.IsNullOrEmpty(groupIds) && string.IsNullOrEmpty(productIds))
216 {
217 if (Pageview.IsVisualEditorMode)
218 {
219 productIds = product.Id;
220 sourceType = "selected";
221 }
222 else
223 {
224 productsFound = false;
225 }
226 }
227 }
228
229 @*Container element for the request*@
230 @if (productsFound)
231 {
232 <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()">
233 <input type="hidden" name="ModelID" value="@Model.ID" />
234
235 @*--- SLIDER SETTINGS ---*@
236 <input type="hidden" name="NavigationStyle" value="@navigationStyle" />
237 <input type="hidden" name="NavigationPlacement" value="@navigationPlacement" />
238 <input type="hidden" name="IndicatorStyle" value="@indicatorStyle" />
239 <input type="hidden" name="RevealSlides" value="@revealSlides" />
240
241 <input type="hidden" name="NavigationAlwaysVisible" value="@(navigationAlwaysVisible)" />
242 <input type="hidden" name="NavigationVisibleOnTouch" value="@(navigationVisibleOnTouch)" />
243 <input type="hidden" name="NavigationShowScrollbar" value="@(navigationShowScrollbar)" />
244 <input type="hidden" name="NavigationSmall" value="@(navigationSmall)" />
245 <input type="hidden" name="NavigationInvertColors" value="@(navigationInvertColors)" />
246 <input type="hidden" name="NavigationNoLoop" value="@(navigationNoLoop)" />
247 <input type="hidden" name="NavigationSlideEntirePage" value="@(navigationSlideEntirePage)" />
248 <input type="hidden" name="IndicatorsOutsideSlider" value="@(indicatorsOutsideSlider)" />
249 <input type="hidden" name="IndicatorsHighlightActive" value="@(indicatorsHighlightActive)" />
250 <input type="hidden" name="IndicatorsInvertColors" value="@(indicatorsInvertColors)" />
251 <input type="hidden" name="IndicatorsVisibleOnSmallDevices" value="@(indicatorsVisibleOnSmallDevices)" />
252
253 @*--- VARIANTS ---*@
254 @if (sourceType == "variants")
255 {
256 <input type="hidden" name="isVariant" value="true" />
257 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
258 }
259
260 @*--- MOST SOLD ---*@
261 @if (sourceType == "most-sold")
262 {
263 <input type="hidden" name="SortBy" value="OrderCount" />
264 if (groupIds != "")
265 {
266 <input type="hidden" name="GroupId" value="@groupIds" />
267 }
268 }
269
270 @*--- TRENDING ---*@
271 @if (sourceType == "trending")
272 {
273 <input type="hidden" name="SortBy" value="OrderCountGrowth" />
274 if (groupIds != "")
275 {
276 <input type="hidden" name="GroupId" value="@groupIds" />
277 }
278 }
279
280 @*--- FREQUENTLY BOUGHT ---*@
281 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds))
282 {
283 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]" />
284 }
285
286 @*--- LATEST ---*@
287 @if (sourceType == "latest")
288 {
289 <input type="hidden" name="SortBy" value="Created" />
290 <input type="hidden" name="GroupId" value="@groupIds" />
291 }
292
293 @*--- SELECTED PRODUCTS ---*@
294 @if (sourceType == "selected")
295 {
296 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
297 }
298
299 @*--- RELATED PRODUCTS ---*@
300 @if (sourceType == "related-products")
301 {
302 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds" />
303 }
304
305 @* General parameters *@
306 <input type="hidden" name="Link" value="@link" />
307 <input type="hidden" name="HideTitle" value="@Model.Item.GetString("HideTitle")" />
308 <input type="hidden" name="SortOrder" value="DESC" />
309 @if (Model.Item.GetInt32("ProductsCount") != 0)
310 {
311 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")" />
312 }
313 <input type="hidden" name="HeadingTitle" id="RelatedProductsTitle_@Model.ID" value="@title" />
314 @if (!string.IsNullOrEmpty(Model.Item.GetString("Subtitle")))
315 {
316 <input type="hidden" name="Subtitle" value="@Model.Item.GetString("Subtitle")" />
317 }
318 @if (!string.IsNullOrEmpty(Model.Item.GetString("LinkText")))
319 {
320 <input type="hidden" name="LinkText" value="@Model.Item.GetString("LinkText")" />
321 }
322 @if (!string.IsNullOrEmpty(Model.Item.GetString("ImageAspectRatio")))
323 {
324 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", "");
325 ratio = ratio != "0" ? ratio : "";
326 <input type="hidden" name="ImageAspectRatio" value="@ratio" />
327 }
328 @if (!string.IsNullOrEmpty(Model.Item.GetString("Layout")))
329 {
330 <input type="hidden" name="Layout" value="@Model.Item.GetRawValueString("Layout")" />
331 }
332 @if (titleFontSize != "")
333 {
334 <input type="hidden" name="TitleFontSize" value="@titleFontSize" />
335 }
336 @if (subtitleFontSize != "")
337 {
338 <input type="hidden" name="SubtitleFontSize" value="@subtitleFontSize" />
339 }
340 @if (buttonStyle != "")
341 {
342 <input type="hidden" name="ButtonStyle" value="@buttonStyle" />
343 }
344 @if (generalTheme != "")
345 {
346 <input type="hidden" name="GeneralTheme" value="@generalTheme" />
347 }
348 @if (theme != "")
349 {
350 <input type="hidden" name="Theme" value="@theme" />
351 }
352 @if (imageTheme != "")
353 {
354 <input type="hidden" name="ImageTheme" value="@imageTheme" />
355 }
356 @if (!string.IsNullOrEmpty(Model.Item.GetString("ContentPadding")))
357 {
358 string contentPadding = Model.Item.GetRawValueString("ContentPadding");
359 <input type="hidden" name="ContentPadding" value="@contentPadding" />
360 }
361 <input type="hidden" name="TextReadability" value="@maxWidth" />
362 <input type="hidden" name="ParentColumnSize" id="ParentColumnSize_@Model.ID" value="12" />
363
364 <input type="hidden" name="SaleBadgeType" value="@Model.Item.GetRawValue("SaleBadgeType")" />
365 <input type="hidden" name="SaleBadgeCssClassName" value="@Model.Item.GetRawValue("SaleBadgeDesign")" />
366 <input type="hidden" name="NewBadgeCssClassName" value="@Model.Item.GetRawValue("NewBadgeDesign")" />
367 <input type="hidden" name="NewPublicationDays" value="@Model.Item.GetInt32("NewPublicationDays")" />
368
369 @if (campaignValues != "")
370 {
371 <input type="hidden" name="CampaignBadgesValues" value="@campaignValues" />
372 }
373 </form>
374
375 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script>
376 <script type="module">
377 swift.AssetLoader.Load('Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css');
378 </script>
379
380 if (sourceType != "related-products")
381 {
382 <div class="w-100 h-100">
383 <div id="RelatedProducts_@Model.ID" class="h-100" style="min-height: 345px"></div>
384 </div>
385 }
386 else if (product?.RelatedGroups != null)
387 {
388 @* Create multiple slider containers, if type is Product relation *@
389 <div class="grid w-100 h-100@(generalTheme)" style="grid-row-gap: 4rem">
390 @foreach (var group in product.RelatedGroups)
391 {
392 <div id="RelatedProducts_@(Model.ID)_@group.Id" class="g-col-12 h-100" style="min-height: 345px"></div>
393 }
394 </div>
395 }
396
397 @* Initialize *@
398 if (sourceType != "related-products")
399 {
400 <script type="module">
401 if (document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]")) {
402 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]").getAttribute("data-col-size");
403 }
404 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID"));
405 </script>
406 }
407 else if (product?.RelatedGroups != null)
408 {
409 @* Create multiple sliders, if type is Product relation *@
410 foreach (var group in product.RelatedGroups)
411 {
412 IList<string> fromProductIds = new List<string> { };
413
414 foreach (var relatedProduct in group.Products)
415 {
416 fromProductIds.Add(relatedProduct.ProductId);
417 }
418 <script type="module">
419 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@(Model.ID)_@group.Id").closest("[data-col-size]").getAttribute("data-col-size");
420 document.querySelector("#MainProductID_@Model.ID").value = "@string.Join(",", fromProductIds)";
421 document.querySelector("#RelatedProductsTitle_@Model.ID").value = "@group.Name";
422 document.querySelector("#RelatedProductsForm_@Model.ID").setAttribute("data-response-target-element", "RelatedProducts_@(Model.ID)_@group.Id");
423
424 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID"));
425 </script>
426 }
427 }
428 }
429
Error executing template "CookieWarning/Cookies.cshtml"
System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at RazorEngine.Roslyn.CSharp.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.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
12 string layout = Pageview.AreaSettings.GetRawValueString("CookieLayout", "modal");
13
14 layout = Pageview.Page.ID == cookieNoticePageID || Pageview.Page.ID == privacyPolicyPageID ? "both" : layout;
15 }
16
17 @if (!Pageview.IsVisualEditorMode) {
18 if (layout == "banner" || layout == "both")
19 {
20 string bannerTheme = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetRawValueString("CookieBannerTheme")) ? " theme " + Pageview.AreaSettings.GetRawValueString("CookieBannerTheme").Replace(" ", "").Trim().ToLower() : "theme light";
21
22 <div class="position-fixed bottom-0 w-100 shadow @bannerTheme" id="dwCookieBanner">
23 <div class="align-items-center grid p-3">
24 @if (layout == "banner")
25 {
26 <div class="g-col-12 g-col-md-6 g-col-lg-8">
27 <span>@Translate("By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Functionality, Statistics and Marketing")</span>
28 </div>
29 <div class="g-col-12 g-col-md-6 g-col-lg-4">
30 <div class="grid grid-1 grid-sm-2">
31 <button type="button" onclick="setOptInCookie(2)" class="btn btn-primary">
32 @Translate("Accept all")
33 </button>
34 <button type="button" onclick="setOptInCookie(0)" class="btn btn-secondary">
35 @Translate("Decline all")
36 </button>
37 </div>
38 </div>
39 }
40 @if (layout == "both")
41 {
42 <div class="g-col-12 g-col-lg-6 g-col-xxl-8">
43 <span>@Translate("By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Functionality, Statistics and Marketing")</span>
44 </div>
45 <div class="g-col-12 g-col-lg-6 g-col-xxl-4">
46 <div class="grid grid-1 grid-sm-3">
47 <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#dwCookieModal">
48 @Translate("Customize settings")
49 </button>
50 <button type="button" onclick="setOptInCookie(2)" class="btn btn-secondary">
51 @Translate("Accept all")
52 </button>
53 <button type="button" onclick="setOptInCookie(0)" class="btn btn-secondary">
54 @Translate("Decline all")
55 </button>
56 </div>
57 </div>
58 }
59 </div>
60 </div>
61 }
62
63 if (layout == "modal" || layout == "both")
64 {
65 string modalTheme = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetRawValueString("CookieModalTheme")) ? " theme " + Pageview.AreaSettings.GetRawValueString("CookieModalTheme").Replace(" ", "").Trim().ToLower() : "theme light";
66
67 <div class="modal fade" id="dwCookieModal">
68 <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" style="max-width:560px;">
69 <div class="modal-content @modalTheme">
70 <div style="overflow-y:auto;overflow-x:hidden">
71 <div class="p-3 p-md-4 overflow-auto" style="max-height:50vh;">
72 <div class="h3 mb-3">@Translate("You control your data")</div>
73 <p>@Translate("We and our partners use technologies, including cookies, to collect information about you for various purposes, including"):</p>
74 <ol>
75 <li>@Translate("Functionality")</li>
76 <li>@Translate("Statistics")</li>
77 <li>@Translate("Marketing")</li>
78 </ol>
79 <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>
80
81 @if (!string.IsNullOrEmpty(cookieNoticeLink) || !string.IsNullOrEmpty(privacyPolicyLink))
82 {
83 <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>
84 }
85
86 @if (!string.IsNullOrEmpty(cookieNoticeLink))
87 {
88 <a href="@cookieNoticeLink" class="d-block mb-3">@Translate("Read more about Cookies")</a>
89 }
90 @if (!string.IsNullOrEmpty(privacyPolicyLink))
91 {
92 <a href="@privacyPolicyLink" class="d-block">@Translate("Our privacy policy")</a>
93 }
94 </div>
95
96 <div class="p-3 px-md-4 border-top">
97 <div class="grid grid-1 grid-sm-2 gap-3">
98 <button type="button" onclick="setOptInCookie(0)" class="btn btn-secondary" data-bs-dismiss="modal" id="dwCookieDeclineAll">@Translate("Decline All")</button>
99 @if (categories.Any())
100 {
101 <button type="button" onclick="acceptCustomSetup()" class="btn btn-secondary d-none" data-bs-dismiss="modal" id="dwCookieAcceptSelected">@Translate("Accept selected")</button>
102 }
103 <button type="button" onclick="setOptInCookie(2)" class="btn btn-secondary" data-bs-dismiss="modal">@Translate("Accept All")</button>
104 </div>
105 </div>
106
107 @if (categories.Any())
108 {
109 int categoriesCount = 0;
110 int totalCategories = categories.Count();
111
112 <form id="dwCookieModalCustomForm" method="post" action="/Admin/Public/CookieOptInLevelConfig.aspx">
113 <input type="hidden" name="cmd" value="SetCookieOptInLevel" />
114 <input type="hidden" name="OptInLevel" id="OptInLevel" value="1" />
115 <div class="grid grid-2 grid-sm-4 gap-0 px-md-3 border-top border-1">
116 <div class="p-3">
117 <label class="form-check-label" for="dwCookieNecessary"><span>@Translate("Necessary")</span></label>
118 <div class="form-check form-switch form-control-lg py-0">
119 <input class="form-check-input opacity-100" type="checkbox" id="dwCookieNecessary" checked disabled style="background-color: rgba(0,0,0,0.1);">
120 </div>
121 </div>
122 @foreach (var category in categories)
123 {
124 string border = categoriesCount < (totalCategories - 1) ? "" : "";
125
126 <div class="p-3 @(border)">
127 <label class="form-check-label" for="CookieCategory_@category"><span>@category</span></label>
128 <div class="form-check form-switch form-control-lg py-0">
129 <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);">
130 </div>
131 </div>
132 categoriesCount++;
133 }
134 </div>
135 </form>
136 }
137 </div>
138 </div>
139 </div>
140 </div>
141 }
142
143
144 <script>
145 async function setOptInCookie(optInLevel) {
146 let response = await fetch("/admin/public/CookieOptInLevelConfig.aspx?cmd=SetCookieOptInLevel&OptInLevel=" + optInLevel);
147
148 if (response.ok) {
149 if (document.querySelector("#dwCookieBanner")) {
150 document.querySelector("#dwCookieBanner").classList.add("d-none");
151 }
152 return false;
153 } else {
154 return false;
155 }
156 }
157
158 async function acceptCustomSetup() {
159 var form = document.querySelector("#dwCookieModalCustomForm");
160
161 let formData = new FormData(form);
162 var fetchOptions = {
163 method: 'POST',
164 body: formData
165 };
166
167 let response = await fetch(form.action, fetchOptions);
168
169 if (response.ok) {
170 if (document.querySelector("#dwCookieBanner")) {
171 document.querySelector("#dwCookieBanner").classList.add("d-none");
172 }
173 return false;
174 } else {
175 return false;
176 }
177 }
178
179 function toggleAcceptSelected() {
180 var cookieCalegoriesElement = document.querySelector("#dwCookieModalCustomForm");
181 var enableAcceptSelected = false;
182
183 cookieCalegoriesElement.querySelectorAll(".js-checkbox").forEach(function (field) {
184 if (field.checked == true) {
185 enableAcceptSelected = true;
186 }
187 });
188
189 if (enableAcceptSelected) {
190 document.querySelector("#dwCookieDeclineAll").classList.add("d-none");
191 document.querySelector("#dwCookieAcceptSelected").classList.remove("d-none");
192 } else {
193 document.querySelector("#dwCookieDeclineAll").classList.remove("d-none");
194 document.querySelector("#dwCookieAcceptSelected").classList.add("d-none");
195 }
196 }
197
198 function showCookieModal() {
199 var cookieModal = new bootstrap.Modal(document.querySelector('#dwCookieModal'), {
200 backdrop: 'static'
201 });
202 cookieModal.show();
203 }
204 </script>
205
206 if (layout == "modal")
207 {
208 <script type="module">
209 showCookieModal();
210 </script>
211 }
212 }
213