//custom rtc js & css Solutii complete pentru mediul de lucru
Error executing template "/Designs/Swift/Paragraph/RTC_PromotionProductImage.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_0b7e79f9192a48cba46e16f67ea2a11a.Execute() in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\RTC_PromotionProductImage.cshtml:line 58
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using System.Text.RegularExpressions 4 5 6 @{ 7 Dynamicweb.Frontend.LinkViewModel link1 = new Dynamicweb.Frontend.LinkViewModel(); 8 Dynamicweb.Frontend.LinkViewModel link2 = new Dynamicweb.Frontend.LinkViewModel(); 9 10 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 11 string layout = Model.Item.GetRawValueString("Layout", "image-top"); 12 string contentPadding = Model.Item.GetRawValueString("ContentPadding", string.Empty); 13 string contentPaddingClass = string.Empty; 14 string gapClass = " gap-3"; 15 16 switch (contentPadding) 17 { 18 case "small": 19 contentPaddingClass = " p-3"; 20 gapClass = " gap-0"; 21 break; 22 case "large": 23 contentPaddingClass = " p-5"; 24 gapClass = " gap-0"; 25 break; 26 } 27 28 ProductViewModel product = new ProductViewModel(); 29 30 ProductViewModelSettings productSetting = new ProductViewModelSettings 31 { 32 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 33 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 34 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 35 ShopId = Pageview.Area.EcomShopId 36 }; 37 38 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 39 { 40 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 41 } else if (Pageview.Item["DummyProduct"] != null) { 42 43 string dummyProductId = ""; 44 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 45 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 46 if (productList.Products != null) 47 { 48 foreach (var p in productList.Products) { dummyProductId = p.Id; } 49 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 50 product = dummyProduct; 51 } else { 52 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 53 } 54 } else if (Pageview.Item["DummyProduct"] == null) { 55 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 56 } 57 58 var startDatePromo = Convert.ToDateTime(product.ProductFields["startpromo"]?.Value); 59 var stopDatePromo = Convert.ToDateTime(product.ProductFields["stoppromo"]?.Value); 60 var textPromo = product.ProductFields["textpromo"]?.Value.ToString(); 61 62 63 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 64 string imgUrl = string.IsNullOrWhiteSpace(product.ProductFields["PromoImagine"]?.Value.ToString()) ? "Files/Images/Banner%20Promotii/PROMO-Gift.jpg" : product.ProductFields["PromoImagine"].Value.ToString(); 65 66 string imgPath = $"/Admin/Public/GetImage.ashx?image={imgUrl}&width=300&format=webp"; 67 string rtcPattern = @"<a\s+(?:[^>]*?\s+)?href=([""'])(.*?)\1"; 68 var rtcMatch = Regex.Match(textPromo, rtcPattern); 69 string rtcTextPattern = @"<a[^>]*>.*?<img[^>]*>.*?</a>"; 70 string textOutput = Regex.Replace(textPromo, rtcTextPattern, string.Empty); 71 72 } 73 74 75 76 77 @if(Convert.ToDateTime(@DateTime.Now.ToString("yyyy-MM-dd")) <= stopDatePromo && Convert.ToDateTime(@DateTime.Now.ToString("yyyy-MM-dd")) >= startDatePromo) { 78 <div class="promo_wrapper d-flex flex-row flex-xs-column"> 79 <div class="promo_wrapper-text col-7 p-3 col-xs-12" style="background: #F4F5F8;"> 80 <div class="d-flex flex-row align-items-center mb-2"> 81 <div class="p-1" style="background:#123384; color:#fff;"> 82 <span class="icon-3"> 83 @ReadFile(iconPath + "gift.svg") 84 </span> 85 </div> 86 <div class="py-1 px-2" style="background: #29ABE2; color:#fff;"> 87 <p class="m-0">Promo</p> 88 </div> 89 </div> 90 @if (!string.IsNullOrWhiteSpace(textOutput) && textOutput.Length > 12) { 91 @textOutput 92 } 93 else { 94 95 <p>Acest produs face parte dintr-o promotie. Click pe imagine pentru detalii!</p> 96 } 97 98 </div> 99 <div class="promo_wrapper-img col-5 p-0 col-xs-12"> 100 @if (rtcMatch.Success) 101 { 102 var rtcUrl = rtcMatch.Groups[2].Value; 103 <a href="@rtcUrl"><img 104 src="@imgPath" 105 alt="Produs in PROMOTIE" 106 loading="lazy" 107 /> 108 </a> } 109 else { 110 <img 111 src="@imgPath" 112 alt="Produs in PROMOTIE" 113 loading="lazy" 114 /> 115 } 116 </div> 117 </div> 118 } 119 120 121 122

Pentru preț și disponibilitate stoc, autentifică-te sau solicită cont

Error executing template "/Designs/Swift/Paragraph/RTC_SimteVerde.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_206b54d9c72b420bbd07bd2a11687b53.Execute() in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\RTC_SimteVerde.cshtml:line 57
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 Dynamicweb.Frontend.LinkViewModel link1 = new Dynamicweb.Frontend.LinkViewModel(); 6 Dynamicweb.Frontend.LinkViewModel link2 = new Dynamicweb.Frontend.LinkViewModel(); 7 8 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 9 string layout = Model.Item.GetRawValueString("Layout", "image-top"); 10 string contentPadding = Model.Item.GetRawValueString("ContentPadding", string.Empty); 11 string contentPaddingClass = string.Empty; 12 string gapClass = " gap-3"; 13 14 switch (contentPadding) 15 { 16 case "small": 17 contentPaddingClass = " p-3"; 18 gapClass = " gap-0"; 19 break; 20 case "large": 21 contentPaddingClass = " p-5"; 22 gapClass = " gap-0"; 23 break; 24 } 25 26 ProductViewModel product = new ProductViewModel(); 27 28 ProductViewModelSettings productSetting = new ProductViewModelSettings 29 { 30 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 31 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 32 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 33 ShopId = Pageview.Area.EcomShopId 34 }; 35 36 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 37 { 38 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 39 } else if (Pageview.Item["DummyProduct"] != null) { 40 41 string dummyProductId = ""; 42 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 43 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 44 if (productList.Products != null) 45 { 46 foreach (var p in productList.Products) { dummyProductId = p.Id; } 47 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 48 product = dummyProduct; 49 } else { 50 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 51 } 52 } else if (Pageview.Item["DummyProduct"] == null) { 53 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 54 } 55 56 bool isProductSimteVerde = false; 57 isProductSimteVerde = (bool)product.ProductFields["SimteVerde"]?.Value; 58 string infoAmbalare = product.ProductFields["InfoAmbalare"]?.Value as string; 59 } 60 61 @if (product.Id.StartsWith("SGR")) 62 { 63 <div class="bg-light p-3 my-2 rounded"> 64 <div class="d-flex align-items-center"> 65 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="#29ABE2" width="30" height="30"> 66 <path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" /> 67 </svg> 68 69 70 <p class="mb-0 text-muted"> <b>SGR</b> - produs la care se aplica taxa de 0.5 lei / ambalaj</p> 71 </div> 72 </div> 73 } 74 75 76 @if (!string.IsNullOrWhiteSpace(infoAmbalare)) 77 { 78 <div class="bg-light p-3 my-2 rounded"> 79 <div class="d-flex align-items-center"> 80 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="#29ABE2" width="30" height="30"> 81 <path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" /> 82 </svg> 83 84 85 <p class="mb-0 text-muted"> <b>INFO</b> - ambalare superioara: @infoAmbalare</p> 86 </div> 87 </div> 88 } 89 90 @if(isProductSimteVerde) { 91 <div class="d-flex flex-row@(gapClass) align-items-center position-relative@(theme) item_@Model.Item.SystemName.ToLower()"> 92 @switch (layout) 93 { 94 case "image-top": 95 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) 96 { 97 @RenderImage() 98 } 99 if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Lead")) || !string.IsNullOrEmpty(Model.Item.GetString("Text")) || link1 != null && !string.IsNullOrEmpty(link1.Url) || link2 != null && !string.IsNullOrEmpty(link2.Url)) 100 { 101 <div class="d-flex flex-column gap-3 h-100@(contentPaddingClass)"> 102 @RenderTitle() 103 @RenderLead() 104 @RenderText() 105 @RenderButtons(link1, link2) 106 </div> 107 } 108 break; 109 } 110 </div> 111 } 112 113 @helper RenderTitle() 114 { 115 bool hideTitle = Model.Item?.GetBoolean("HideTitle") ?? false; 116 string title = !hideTitle ? Model.Item.GetString("Title", string.Empty) : string.Empty; 117 118 if (!string.IsNullOrEmpty(title)) 119 { 120 string maxWidth = Model.Item.GetRawValueString("TextReadability", string.Empty) == "max-width-on" ? " mw-75ch" : string.Empty; 121 string titleFontSize = Model.Item.GetString("TitleFontSize", "h2"); 122 string titleColor = Model.Item.GetString("TitleColor", "text-inherit"); 123 string titleOpacity = Model.Item.GetString("TitleOpacity", "opacity-100"); 124 125 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 126 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {titleColor} {titleOpacity}{maxWidth} m-0\">"; 127 string headingLevelStop = $"</{headingLevel}>"; 128 129 @headingLevelStart 130 @title 131 @headingLevelStop 132 } 133 } 134 135 @helper RenderLead() 136 { 137 if (!string.IsNullOrEmpty(Model.Item.GetString("Lead"))) 138 { 139 string subtitleColor = Model.Item.GetString("SubtitleColor", "text-inherit"); 140 string subtitleOpacity = Model.Item.GetString("SubtitleOpacity", "opacity-100"); 141 string maxWidth = Model.Item.GetRawValueString("TextReadability", string.Empty) == "max-width-on" ? " mw-75ch" : string.Empty; 142 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 143 144 <p class="m-0 lead @(subtitleFontSize) @(subtitleColor) @(subtitleOpacity)@(maxWidth)"> 145 @Model.Item.GetString("Lead") 146 </p> 147 } 148 } 149 150 @helper RenderText() 151 { 152 if (!string.IsNullOrEmpty(Model.Item.GetString("Text"))) 153 { 154 string maxWidth = Model.Item.GetRawValueString("TextReadability", string.Empty) == "max-width-on" ? " mw-75ch" : string.Empty; 155 string textColor = Model.Item.GetString("TextColor", "text-inherit"); 156 string textOpacity = Model.Item.GetString("TextOpacity", "opacity-100"); 157 158 <div class="mb-0-last-child @textColor @(textOpacity)@(maxWidth)"> 159 @Model.Item.GetString("Text") 160 </div> 161 } 162 } 163 164 @helper RenderImage() 165 { 166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) 167 { 168 int xPos = Model.Item?.GetFile("Image")?.FocalPositionFromLeft ?? 50; 169 int yPos = Model.Item?.GetFile("Image")?.FocalPositionFromTop ?? 50; 170 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : string.Empty; 171 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : string.Empty; 172 string imageAspect = Model.Item.GetRawValueString("ImageAspectRatio", string.Empty); 173 string ImageObjectFit = Model.Item.GetRawValueString("ImageObjectFit", string.Empty); 174 ImageObjectFit = ImageObjectFit == "cover" ? string.Empty : ImageObjectFit; 175 ImageObjectFit = ImageObjectFit == "contain" ? "object-fit:contain" : ImageObjectFit; 176 177 var parms = new Dictionary<string, object>(); 178 parms.Add("loading", "lazy"); 179 parms.Add("style", ImageObjectFit); 180 parms.Add("alt", Model.Item.GetString("ImageAltText")); 181 parms.Add("columns", Model.GridRowColumnCount); 182 183 if (Model.Item.GetRawValueString("ImageAspectRatio") == "0") 184 { 185 parms.Add("fullwidth", true); 186 parms.Add("cssClass", "w-200"); 187 188 if (Model.Item.GetString("Layout") == "text-center") 189 { 190 <figure class="d-flex flex-column align-items-center"> 191 @RenderPartial("Components/Image.cshtml", Model.Item.GetFile("Image") ?? new Dynamicweb.Frontend.FileViewModel(), parms) 192 </figure> 193 } 194 else 195 { 196 <figure class="m-0"> 197 @RenderPartial("Components/Image.cshtml", Model.Item.GetFile("Image") ?? new Dynamicweb.Frontend.FileViewModel(), parms) 198 </figure> 199 } 200 } 201 else 202 { 203 <figure class="mb-0 @ratioCssClass" @ratioVariable> 204 @RenderPartial("Components/Image.cshtml", Model.Item.GetFile("Image") ?? new Dynamicweb.Frontend.FileViewModel(), parms) 205 </figure> 206 207 } 208 } 209 } 210 211 @helper RenderButtons(Dynamicweb.Frontend.LinkViewModel link1, Dynamicweb.Frontend.LinkViewModel link2) 212 { 213 string linkType = Model.Item.GetRawValueString("LinkType", "page"); 214 string linkType2 = Model.Item.GetRawValueString("LinkType2", "page2"); 215 216 if (linkType == "page" && Model.Item.GetLink("ButtonLink") != null) 217 { 218 link1 = Model.Item.GetLink("ButtonLink"); 219 } 220 221 if (linkType2 == "page2" && Model.Item.GetLink("ButtonLink2") != null) 222 { 223 link2 = Model.Item.GetLink("ButtonLink2"); 224 } 225 226 if (linkType == "product-group") 227 { 228 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink"); 229 IList<string> groupIds = new List<string> { }; 230 231 if (selectedGroups != null) 232 { 233 foreach (var fromGroup in selectedGroups) 234 { 235 groupIds.Add(fromGroup.Id); 236 } 237 } 238 239 link1 = new Dynamicweb.Frontend.LinkViewModel() 240 { 241 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(), 242 IsExternal = false 243 }; 244 } 245 246 if (linkType2 == "product-group2") 247 { 248 IList<ProductGroupViewModel> selectedGroups = Model.Item.GetValue<IList<ProductGroupViewModel>>("ProductGroupLink2"); 249 IList<string> groupIds = new List<string> { }; 250 251 if (selectedGroups != null) 252 { 253 foreach (var fromGroup in selectedGroups) 254 { 255 groupIds.Add(fromGroup.Id); 256 } 257 } 258 259 link2 = new Dynamicweb.Frontend.LinkViewModel() 260 { 261 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(), 262 IsExternal = false 263 }; 264 } 265 266 if (linkType == "product") 267 { 268 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink"); 269 IList<string> productIds = new List<string> { }; 270 271 if (products != null) 272 { 273 foreach (var product in products.Products) 274 { 275 productIds.Add(product.Id); 276 } 277 } 278 279 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 280 string pageTag = productIds.Count == 1 ? "ProductDetailPage" : "Shop"; 281 link1 = new Dynamicweb.Frontend.LinkViewModel() 282 { 283 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag(pageTag) + "&" + productParameter + "=" + string.Join(",", productIds).Trim(), 284 IsExternal = false 285 }; 286 } 287 288 if (linkType2 == "product2") 289 { 290 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("ProductLink2"); 291 IList<string> productIds = new List<string> { }; 292 293 if (products != null) 294 { 295 foreach (var product in products.Products) 296 { 297 productIds.Add(product.Id); 298 } 299 } 300 301 string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; 302 string pageTag = productIds.Count == 1 ? "ProductDetailPage" : "Shop"; 303 link2 = new Dynamicweb.Frontend.LinkViewModel() 304 { 305 Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag(pageTag) + "&" + productParameter + "=" + string.Join(",", productIds).Trim(), 306 IsExternal = false 307 }; 308 } 309 310 if (link1 != null && !string.IsNullOrEmpty(link1.Url) || link2 != null && !string.IsNullOrEmpty(link2.Url)) 311 { 312 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", "primary"); 313 buttonStyle = buttonStyle == "primary" ? " btn-primary" : buttonStyle; 314 buttonStyle = buttonStyle == "secondary" ? " btn-secondary" : buttonStyle; 315 buttonStyle = buttonStyle == "link" ? " btn-link" : buttonStyle; 316 string buttonStyle2 = Model.Item.GetRawValueString("ButtonStyle2", "secondary"); 317 buttonStyle2 = buttonStyle2 == "primary" ? " btn-primary" : buttonStyle2; 318 buttonStyle2 = buttonStyle2 == "secondary" ? " btn-secondary" : buttonStyle2; 319 buttonStyle2 = buttonStyle2 == "link" ? " btn-link" : buttonStyle2; 320 string target1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "target=\"_blank\"" : string.Empty; 321 string target2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "target=\"_blank\"" : string.Empty; 322 string rel1 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link1.IsExternal ? "rel=\"noopener\"" : string.Empty; 323 string rel2 = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && link2.IsExternal ? "rel=\"noopener\"" : string.Empty; 324 string buttonLabel = Model.Item.GetString("ButtonLabel", string.Empty); 325 string buttonLabel2 = Model.Item.GetString("ButtonLabel2", string.Empty); 326 string stretchedLink = Model.Item.GetRawValueString("StretchedLink", "column-not-clickable"); 327 string stretchedLink2 = Model.Item.GetRawValueString("StretchedLink2", "column-not-clickable"); 328 string stretchedLinkClass = stretchedLink == "column-clickable" && string.IsNullOrEmpty(link2.Url) && string.IsNullOrEmpty(buttonLabel2) ? " stretched-link" : string.Empty; 329 string stretchedLinkClass2 = stretchedLink2 == "column-clickable" && string.IsNullOrEmpty(link1.Url) && string.IsNullOrEmpty(buttonLabel) ? " stretched-link" : string.Empty; 330 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 331 buttonSize = buttonSize == "small" ? " btn-sm" : buttonSize; 332 buttonSize = buttonSize == "regular" ? string.Empty : buttonSize; 333 buttonSize = buttonSize == "large" ? " btn-lg" : buttonSize; 334 string alignmentClass = string.Empty; 335 336 if (Model.Item.GetString("Layout") == "text-center") 337 { 338 alignmentClass = " justify-content-center"; 339 } 340 341 <div class="d-flex flex-wrap gap-3@(alignmentClass)"> 342 343 @if (link1 != null && !string.IsNullOrEmpty(link1.Url)) 344 { 345 if (!string.IsNullOrEmpty(buttonLabel)) 346 { 347 <a href="@link1.Url" @target1 @rel1 class="text-nowrap btn@(buttonStyle)@(buttonSize)@(stretchedLinkClass)">@buttonLabel</a> 348 } 349 else 350 { 351 <a href="@link1.Url" @target1 @rel1 class="@(stretchedLinkClass)"> 352 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 353 </a> 354 } 355 } 356 357 @if (link2 != null && !string.IsNullOrEmpty(link2.Url)) 358 { 359 if (!string.IsNullOrEmpty(buttonLabel2)) 360 { 361 <a href="@link2.Url" @target2 @rel2 class="text-nowrap btn@(buttonStyle2)@(buttonSize)@(stretchedLinkClass2)">@buttonLabel2</a> 362 } 363 else 364 { 365 <a href="@link2.Url" @target2 @rel2 class="@(stretchedLinkClass)"> 366 <span class="visually-hidden">@Model.Item.GetString("Title")</span> 367 </a> 368 } 369 } 370 </div> 371 } 372 } 373

Depunem un efort constant pentru pastrarea acuratetii informatiilor. In unele cazuri specificatiile si informatiile prezentate pe site-ul www.RTC.ro pot contine mici inadvertente.
Fotografiile produselor au caracter informativ, pot contine accesorii neincluse in pachetele standard si nu reprezinta obligatie contractuala.

Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsGallery.cshtml"
System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)
   at CompiledRazorTemplates.Dynamic.RazorEngine_41830a90ab3547d3b0a6969cd68e0806.Execute() in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsGallery.cshtml:line 77
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Frontend 4 @using System.IO 5 6 @functions { 7 public ProductViewModel product { get; set; } = new ProductViewModel(); 8 public string galleryLayout { get; set; } 9 public string[] supportedImageFormats { get; set; } 10 public string[] supportedVideoFormats { get; set; } 11 public string[] supportedDocumentFormats { get; set; } 12 public string[] allSupportedFormats { get; set; } 13 14 public class RatioSettings { 15 public string Ratio { get; set; } 16 public string CssClass { get; set; } 17 public string CssVariable { get; set; } 18 public string Fill { get; set; } 19 } 20 21 public RatioSettings GetRatioSettings(string size = "desktop") { 22 var ratioSettings = new RatioSettings(); 23 24 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 25 ratio = ratio != "0" ? ratio : ""; 26 string cssClass = ratio != "" && ratio != "fill" ? " ratio" : ""; 27 string cssVariable = ratio != "" && ratio != "fill" ? "--bs-aspect-ratio: " + ratio : ""; 28 cssClass = ratio != "" && ratio == "fill" && size == "mobile" ? " ratio" : cssClass; 29 cssVariable = ratio != "" && ratio == "fill" && size == "mobile" ? "--bs-aspect-ratio: 66%" : cssVariable; 30 31 ratioSettings.Ratio = ratio; 32 ratioSettings.CssClass = cssClass; 33 ratioSettings.CssVariable = cssVariable; 34 ratioSettings.Fill = ratio == "fill" ? " h-100" : ""; 35 36 return ratioSettings; 37 } 38 39 public string GetColumnClass(int total, int assetNumber) { 40 string colClass = total > 1 ? "g-col-lg-6" : "g-col-12"; 41 colClass = galleryLayout == "full-first" && assetNumber == 0 ? "g-col-12" : colClass; 42 colClass = galleryLayout == "full-last" && assetNumber == (total - 1) ? "g-col-12" : colClass; 43 colClass = galleryLayout == "advanced-grid" && assetNumber > 1 ? "g-col-4" : colClass; 44 45 colClass = galleryLayout == "advanced-grid" && total == 1 ? "g-col-12" : colClass; 46 colClass = galleryLayout == "advanced-grid" && total == 3 && assetNumber == 2 ? "g-col-12" : colClass; 47 colClass = galleryLayout == "advanced-grid" && total == 4 && assetNumber == 2 ? "g-col-6" : colClass; 48 colClass = galleryLayout == "advanced-grid" && total == 4 && assetNumber == 3 ? "g-col-6" : colClass; 49 colClass = galleryLayout == "advanced-grid" && total == 6 && assetNumber == 5 ? "g-col-12" : colClass; 50 colClass = galleryLayout == "advanced-grid" && total == 7 && assetNumber == 5 ? "g-col-6" : colClass; 51 colClass = galleryLayout == "advanced-grid" && total == 7 && assetNumber == 6 ? "g-col-6" : colClass; 52 colClass = galleryLayout == "advanced-grid" && total == 9 && assetNumber == 8 ? "g-col-12" : colClass; 53 54 return colClass; 55 } 56 } 57 58 @{ 59 @* Get the product data *@ 60 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 61 { 62 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 63 } 64 65 @* Supported formats *@ 66 supportedImageFormats = new string[] { ".jpg", ".jpeg", ".webp", ".png", ".gif", ".bmp", ".tiff" }; 67 supportedVideoFormats = new string[] { "youtu.be", "youtube", "vimeo", ".mp4", ".webm" }; 68 supportedDocumentFormats = new string[] { ".pdf", ".docx", ".xlsx", ".ppt", "pptx" }; 69 allSupportedFormats = supportedImageFormats.Concat(supportedVideoFormats).Concat(supportedDocumentFormats).ToArray(); 70 71 @* Collect the assets *@ 72 var selectedAssetCategories = Model.Item.GetRawValueString("ImageAssets").Split(',').ToList(); 73 bool includeImagePatternImages = Model.Item.GetBoolean("ImagePatternImages"); 74 75 @* Needed image data collection to support both DefaultImage, ImagePatterns and Image Assets *@ 76 string defaultImage = product.DefaultImage != null ? product.DefaultImage.Value : ""; 77 IEnumerable<MediaViewModel> assetsImages = product.AssetCategories.Where(x => selectedAssetCategories.Contains(x.SystemName)).SelectMany(x => x.Assets); 78 assetsImages = assetsImages.OrderByDescending(x => x.Value.Equals(defaultImage)); 79 IEnumerable<MediaViewModel> assetsList = new MediaViewModel[]{}; 80 assetsList = assetsList.Union(assetsImages); 81 assetsList = includeImagePatternImages ? assetsList.Union(product.ImagePatternImages) : assetsList; 82 assetsList = includeImagePatternImages && assetsList.Count() == 0 ? assetsList.Append(product.DefaultImage) : assetsList; 83 84 bool defaultImageFallback = Model.Item.GetBoolean("DefaultImageFallback"); 85 86 int totalAssets = 0; 87 foreach (MediaViewModel asset in assetsList) { 88 var assetValue = asset.Value.ToLower(); 89 foreach (string format in allSupportedFormats) { 90 if (assetValue.Contains(format) ) { 91 totalAssets++; 92 } 93 } 94 } 95 96 if (totalAssets == 0) 97 { 98 if (defaultImageFallback) { 99 assetsList = new List<MediaViewModel>(){ product.DefaultImage }; 100 totalAssets = 1; 101 } else { 102 assetsList = new List<MediaViewModel>(){ }; 103 totalAssets = 0; 104 } 105 } 106 107 @* Layout settings *@ 108 string spacing = Model.Item.GetRawValueString("Spacing", "4"); 109 spacing = spacing == "none" ? "gap-0" : spacing; 110 spacing = spacing == "small" ? "gap-3" : spacing; 111 spacing = spacing == "large" ? "gap-4" : spacing; 112 113 galleryLayout = Model.Item.GetRawValueString("Layout", "grid"); 114 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 115 116 var badgeParms = new Dictionary<string, object>(); 117 badgeParms.Add("size", "h5"); 118 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 119 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 120 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 121 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 122 badgeParms.Add("campaignBadgesValues", Model.Item.GetRawValueString("CampaignBadges")); 123 124 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 125 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 126 DateTime createdDate = product.Created.Value; 127 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 128 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 129 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 130 } 131 132 @* Get assets from selected categories or get all assets *@ 133 @if (totalAssets != 0 && assetsList.Count() != 0) { 134 int desktopAssetNumber = 0; 135 int mobileAssetNumber = 0; 136 int mobileAssetThumbnailNumber = 0; 137 int modalAssetNumber = 0; 138 139 @* Desktop: Show the gallery on large screens *@ 140 <div class="d-none d-lg-block h-100 position-relative @theme item_@Model.Item.SystemName.ToLower() desktop"> 141 <div class="grid @spacing"> 142 @foreach (MediaViewModel asset in assetsList) { 143 var assetName = asset.Value.ToLower(); 144 foreach (string format in allSupportedFormats) { 145 if (assetName.Contains(format)) { 146 <div class="@GetColumnClass(totalAssets, desktopAssetNumber)"> 147 @{@RenderAsset(asset, desktopAssetNumber)} 148 </div> 149 desktopAssetNumber++; 150 } 151 } 152 } 153 </div> 154 155 @if (showBadges) { 156 <div class="position-absolute top-0 left-0 p-2 p-lg-3 w-100"> 157 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 158 </div> 159 } 160 </div> 161 162 @* Mobile: Show the thumbs on small screens *@ 163 <div class="d-block d-lg-none mx-lg-0 position-relative @theme item_@Model.Item.SystemName.ToLower() mobile d-xs-flex flex-xs-column "> 164 <div id="SmallScreenImages_@Model.ID" class="carousel" data-bs-ride="carousel"> 165 <div class="carousel-inner h-100"> 166 @foreach (MediaViewModel asset in assetsList) { 167 var assetValue = asset.Value.ToLower(); 168 foreach (string format in allSupportedFormats) { 169 if (assetValue.Contains(format)) { 170 string activeSlide = mobileAssetNumber == 0 ? "active" : ""; 171 172 <div class="carousel-item @activeSlide" data-bs-interval="99999"> 173 @{@RenderAsset(asset, mobileAssetNumber, "mobile")} 174 </div> 175 mobileAssetNumber++; 176 } 177 } 178 } 179 </div> 180 </div> 181 182 @if (totalAssets > 1) { 183 <div id="SmallScreenImagesThumbnails_@Model.ID" class="d-flex flex-nowrap gap-2 overflow-x-auto my-3"> 184 @foreach (MediaViewModel asset in assetsList) { 185 var assetValue = asset.Value; 186 foreach (string format in allSupportedFormats) { 187 if (assetValue.Contains(format) ) { 188 string imagePath = Dynamicweb.Context.Current.Server.UrlEncode(assetValue); 189 imagePath = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "https://img.youtube.com/vi/" + assetValue.Substring(assetValue.LastIndexOf('/') + 1) + "/default.jpg" : imagePath; 190 string imagePathThumb = !imagePath.Contains("youtube") ? $"/Admin/Public/GetImage.ashx?image={imagePath}&width=160&format=webp" : imagePath; 191 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 192 193 string videoId = assetValue.Substring(assetValue.LastIndexOf('/') + 1); 194 string vimeoJsClass = assetValue.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 195 196 string productName = product.Name; 197 productName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 198 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 199 200 <div class="ratio ratio-4x3 border outline-none" style="flex:0 0 80px" data-bs-target="#SmallScreenImages_@Model.ID" data-bs-slide-to="@mobileAssetThumbnailNumber"> 201 @foreach (string videoFormat in supportedVideoFormats) { 202 if (assetValue.Contains(videoFormat)) { 203 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 204 <div class="icon-3 position-absolute text-light" style="z-index: 1">@ReadFile(iconPath+"play-circle.svg")</div> 205 </div> 206 } 207 } 208 <img src="@imagePathThumb" class="p-1 @vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;" alt="@productName" @assetTitle > 209 </div> 210 211 mobileAssetThumbnailNumber++; 212 } 213 } 214 } 215 </div> 216 } 217 218 @if (showBadges) { 219 <div class="position-absolute top-0 left-0 p-2 p-lg-3"> 220 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 221 </div> 222 } 223 </div> 224 225 @* Modal with slides *@ 226 <div class="modal fade swift_products-details-images-modal" id="modal_@Model.ID" tabindex="-1" aria-labelledby="productDetailsGalleryModalTitle_@Model.ID" aria-hidden="true"> 227 <div class="modal-dialog modal-dialog-centered modal-xl"> 228 <div class="modal-content"> 229 <div class="modal-header visually-hidden"> 230 <h5 class="modal-title" id="productDetailsGalleryModalTitle_@Model.ID">@product.Title</h5> 231 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 232 </div> 233 <div class="modal-body p-2 p-lg-3 h-100"> 234 <div id="ModalCarousel_@Model.ID" class="carousel h-100" data-bs-ride="carousel"> 235 <div class="carousel-inner h-100 @theme"> 236 @foreach (MediaViewModel asset in assetsList) { 237 var assetValue = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 238 foreach (string format in allSupportedFormats) { 239 if (assetValue.Contains(format) ) { 240 string imagePath = assetValue; 241 string activeSlide = modalAssetNumber == 0 ? "active" : ""; 242 243 var parms = new Dictionary<string, object>(); 244 parms.Add("cssClass", "d-block mw-100 mh-100 m-auto"); 245 parms.Add("fullwidth", true); 246 parms.Add("columns", Model.GridRowColumnCount); 247 248 <div class="carousel-item @activeSlide h-100" data-bs-interval="99999"> 249 @foreach (string imageFormat in supportedImageFormats) { 250 if (assetValue.Contains(imageFormat)) { 251 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 252 } 253 } 254 255 @foreach (string videoFormat in supportedVideoFormats) { 256 if (assetValue.Contains(videoFormat)) { 257 {@RenderVideoPlayer(asset, "modal")} 258 } 259 } 260 </div> 261 262 modalAssetNumber++; 263 } 264 } 265 } 266 <button class="carousel-control-prev" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="prev"> 267 <span class="carousel-control-prev-icon" aria-hidden="true"></span> 268 <span class="visually-hidden">@Translate("Previous")</span> 269 </button> 270 <button class="carousel-control-next" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="next"> 271 <span class="carousel-control-next-icon" aria-hidden="true"></span> 272 <span class="visually-hidden">@Translate("Next")</span> 273 </button> 274 </div> 275 </div> 276 </div> 277 </div> 278 </div> 279 </div> 280 } else if (Pageview.IsVisualEditorMode) { 281 RatioSettings ratioSettings = GetRatioSettings("desktop"); 282 283 <div class="h-100 @theme"> 284 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)"> 285 <img src="/Files/Images/missing_image.jpg" loading="lazy" decoding="async" class="mh-100 mw-100" style="object-fit: cover;" alt="@Translate("Missing image")"> 286 </div> 287 </div> 288 } 289 290 @helper RenderAsset(MediaViewModel asset, int assetNumber, string size = "desktop") { 291 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 292 string assetValue = asset.Value; 293 294 <div class="h-100 @(theme)"> 295 @foreach (string format in supportedImageFormats) { //Images 296 if (assetValue.Contains(format)) { 297 {@RenderImage(asset, assetNumber, size)} 298 } 299 } 300 @foreach (string format in supportedVideoFormats) { //Videos 301 if (assetValue.Contains(format)) { 302 if (Model.Item.GetString("OpenVideoInModal") == "true") { 303 {@RenderVideoScreendump(asset, assetNumber, size)} 304 } else { 305 {@RenderVideoPlayer(asset, size)} 306 } 307 } 308 } 309 @foreach (string format in supportedDocumentFormats) { //Documents 310 if (assetValue.Contains(format)) { 311 {@RenderDocument(asset, assetNumber, size)} 312 } 313 } 314 </div> 315 } 316 317 @helper RenderImage(MediaViewModel asset, int number, string size = "desktop") { 318 string productName = product.Name; 319 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 320 string imageLinkPath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 321 322 RatioSettings ratioSettings = GetRatioSettings(size); 323 324 var parms = new Dictionary<string, object>(); 325 parms.Add("alt", productName); 326 parms.Add("itemprop", "image"); 327 parms.Add("fullwidth", true); 328 parms.Add("columns", Model.GridRowColumnCount); 329 if (!string.IsNullOrEmpty(asset.DisplayName)) { 330 parms.Add("title", asset.DisplayName); 331 } 332 333 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") { 334 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 335 } else { 336 parms.Add("cssClass", "mw-100 mh-100"); 337 } 338 339 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 340 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@number"> 341 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 342 </div> 343 </a> 344 } 345 346 @helper RenderVideoScreendump(MediaViewModel asset, int number, string size = "desktop") { 347 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 348 349 string videoScreendumpPath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : ""; 350 string videoId = videoScreendumpPath.Substring(videoScreendumpPath.LastIndexOf('/') + 1); 351 videoScreendumpPath = videoScreendumpPath.Contains("youtu.be") || videoScreendumpPath.Contains("youtube") ? "https://img.youtube.com/vi/" + videoId + "/maxresdefault.jpg" : videoScreendumpPath; 352 353 string vimeoJsClass = videoScreendumpPath.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 354 videoScreendumpPath = videoScreendumpPath.Contains("vimeo") ? "" : videoScreendumpPath; 355 356 string productName = product.Name; 357 productName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 358 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 359 360 RatioSettings ratioSettings = GetRatioSettings(size); 361 362 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable); cursor: pointer" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 363 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@number"> 364 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> 365 <img src="@videoScreendumpPath" loading="lazy" decoding="async" alt="@productName" @assetTitle class="@vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;"> 366 </div> 367 </div> 368 } 369 370 @helper RenderVideoPlayer(MediaViewModel asset, string size = "desktop") { 371 string assetName = !string.IsNullOrEmpty(asset.DisplayName) ? asset.DisplayName : asset.Name; 372 string assetValue = asset.Value; 373 string videoId = asset.Value.Substring(asset.Value.LastIndexOf('/') + 1); 374 string type = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "youtube" : ""; 375 type = assetValue.Contains("vimeo") ? "vimeo" : type; 376 type = assetValue.Contains(".mp4") || assetValue.Contains(".webm") ? "selfhosted" : type; 377 378 string openInModal = Model.Item.GetString("OpenVideoInModal"); 379 bool autoPlay = Model.Item.GetBoolean("VideoAutoPlay"); 380 381 <div class="h-100" itemscope itemtype="https://schema.org/VideoObject"> 382 <span class="visually-hidden" itemprop="name">@assetName</span> 383 <span class="visually-hidden" itemprop="contentUrl">@asset.Value</span> 384 <span class="visually-hidden" itemprop="thumbnailUrl">@asset.Value</span> 385 @if (type != "selfhosted") { 386 <div 387 id="player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size" 388 class="plyr__video-embed" 389 data-plyr-provider="@(type)" 390 data-plyr-embed-id="@videoId" 391 style="--plyr-color-main: var(--swift-foreground-color); height: 100%"> 392 </div> 393 394 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/plyr.js"></script> 395 396 <script type="module"> 397 var player = new Plyr('#player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size', { 398 type: 'video', 399 youtube: { 400 noCookie: true, 401 showinfo: 0 402 }, 403 fullscreen: { 404 enabled: true, 405 iosNative: true, 406 } 407 }); 408 409 @if (autoPlay && openInModal == "false") { 410 <text> 411 player.config.autoplay = true; 412 player.config.muted = true; 413 player.config.volume = 0; 414 player.media.loop = true; 415 416 player.on('ready', function() { 417 if (player.config.autoplay === true) { 418 player.media.play(); 419 } 420 }); 421 </text> 422 } 423 424 @if (openInModal == "true") { 425 <text> 426 var productDetailsGalleryModal = document.querySelector('#modal_@Model.ID') 427 productDetailsGalleryModal.addEventListener('hidden.bs.modal', function (event) { 428 player.media.pause(); 429 }) 430 </text> 431 } 432 </script> 433 } else { 434 string autoPlayAttributes = (autoPlay && openInModal == "false") ? "loop autoplay muted playsinline" : ""; 435 string videoType = Path.GetExtension(assetValue).ToLower(); 436 437 <video preload="auto" @autoPlayAttributes class="h-100 w-100" style="object-fit: cover;"> 438 <source src="@assetValue" type="video/@videoType.Replace(".", "")"> 439 </video> 440 } 441 </div> 442 } 443 444 @helper RenderDocument(MediaViewModel asset, int number, string size = "desktop") { 445 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 446 447 string productName = product.Name; 448 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 449 string imageLinkPath = imagePath; 450 451 RatioSettings ratioSettings = GetRatioSettings(size); 452 453 var parms = new Dictionary<string, object>(); 454 parms.Add("alt", productName); 455 parms.Add("itemprop", "image"); 456 parms.Add("fullwidth", true); 457 parms.Add("columns", Model.GridRowColumnCount); 458 if (!string.IsNullOrEmpty(asset.DisplayName)) { 459 parms.Add("title", asset.DisplayName); 460 } 461 462 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") { 463 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 464 } else { 465 parms.Add("cssClass", "mw-100 mh-100"); 466 } 467 468 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" download title="@Translate("Download")"> 469 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 470 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "download.svg")</div> 471 @if (asset.Value.Contains(".pdf")) { 472 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 473 } else { 474 475 } 476 </div> 477 </a> 478 } 479
no product field found
Error executing template "/Designs/Swift/Paragraph/RTC_AssortmentCheck.cshtml"
System.Data.SqlClient.SqlException (0x80131904): The parameterized query '(@UserID nvarchar(5),@ProductID nvarchar(4000))
WITH UserGroupT' expects the parameter '@ProductID', which was not supplied.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at CompiledRazorTemplates.Dynamic.RazorEngine_6bebdc90f7a6477db0ed9e5a2968aa90.UserHasAccessToProduct(String UserID, String ProductID) in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\RTC_AssortmentCheck.cshtml:line 148
   at CompiledRazorTemplates.Dynamic.RazorEngine_6bebdc90f7a6477db0ed9e5a2968aa90.Execute() in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\RTC_AssortmentCheck.cshtml:line 56
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
ClientConnectionId:b9403218-e934-4fc5-b974-79f0aea13af6
Error Number:8178,State:1,Class:16

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 ProductViewModel product = new ProductViewModel(); 6 7 ProductViewModelSettings productSetting = new ProductViewModelSettings 8 { 9 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 10 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 11 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 12 ShopId = Pageview.Area.EcomShopId 13 }; 14 15 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 16 { 17 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 18 19 } else if (Pageview.Item["DummyProduct"] != null) { 20 string dummyProductId = ""; 21 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 22 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 23 if (productList.Products != null) 24 { 25 foreach (var p in productList.Products) { dummyProductId = p.Id; } 26 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 27 product = dummyProduct; 28 } else { 29 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 30 } 31 } else if (Pageview.Item["DummyProduct"] == null) { 32 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 33 } 34 35 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 36 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 37 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 38 39 var productIDx = ""; 40 41 try 42 { 43 productIDx = product.Id; 44 } 45 catch (Exception ex) 46 { 47 productIDx = "no product field found"; 48 } 49 } 50 51 @{ 52 var userIDx = (Pageview.User != null) ? Pageview.User.ID.ToString() : "56895"; 53 54 } 55 56 @if (!UserHasAccessToProduct(userIDx, productIDx)) { 57 58 <script> 59 var overlay = document.createElement('div'); 60 overlay.style.width = '100%'; 61 overlay.style.height = '100%'; 62 overlay.style.backgroundColor = 'rgba(0, 0, 23, 0.99)'; 63 overlay.style.zIndex = '1000'; 64 overlay.style.top = '0'; 65 overlay.style.left = '0'; 66 overlay.classList.add('position-fixed'); 67 var button = document.createElement('button'); 68 button.textContent = 'Nu ai acces la acest produs!'; 69 button.classList.add('btn', 'btn-primary'); 70 button.style.position = 'absolute'; 71 button.style.top = '50%'; 72 button.style.left = '50%'; 73 button.style.transform = 'translate(-50%, -50%)'; 74 button.addEventListener('click', function() { 75 window.location.href = '/'; 76 }); 77 78 79 overlay.appendChild(button); 80 81 82 document.body.appendChild(overlay); 83 84 85 </script> 86 } 87 88 89 90 @functions { 91 public bool UserHasAccessToProduct(string UserID, string ProductID) 92 { 93 bool hasAccess = false; 94 using (var command = Dynamicweb.Data.Database.CreateConnection().CreateCommand()) 95 { 96 command.CommandText = @" 97 WITH UserGroupTable AS (SELECT a.[GroupId] 98 ,a.[AccessUserID] 99 100 FROM [altexrtc.cloud.dynamicweb-cms.com].[dbo].[vwGroupUsers] AS a 101 INNER JOIN AccessUser AS b 102 ON a.GroupId = b.AccessUserID 103 104 WHERE a.AccessUserID = @UserID 105 AND b.AccessUserCustomerNumber = a.AccessUserCustomerNumber 106 ), 107 CombinedUserGroupTable AS ( 108 SELECT 109 AccessUserID, 110 NULL AS GroupID 111 FROM [AccessUser] 112 WHERE AccessUserID = @UserID 113 UNION ALL 114 SELECT 115 AccessUserID, 116 GroupID 117 FROM UserGroupTable 118 ) 119 SELECT 120 CASE 121 WHEN COUNT(*) > 0 THEN 'True' 122 ELSE 'False' 123 END AS UserHasAccess 124 FROM CombinedUserGroupTable c 125 JOIN [EcomAssortmentPermissions] p 126 ON c.AccessUserID = p.AssortmentPermissionAccessUserID OR c.GroupID = p.AssortmentPermissionAccessUserID 127 JOIN [EcomAssortmentItems] a 128 ON p.AssortmentPermissionAssortmentID = a.AssortmentItemAssortmentID 129 WHERE a.AssortmentItemProductID = @ProductID 130 "; 131 132 133 134 command.Parameters.Add(new System.Data.SqlClient.SqlParameter() 135 { 136 ParameterName = "UserID", 137 SqlDbType = System.Data.SqlDbType.NVarChar, 138 Value = UserID 139 }); 140 141 command.Parameters.Add(new System.Data.SqlClient.SqlParameter() 142 { 143 ParameterName = "ProductID", 144 SqlDbType = System.Data.SqlDbType.NVarChar, 145 Value = ProductID 146 }); 147 148 using (var reader = command.ExecuteReader()) 149 { 150 if (reader.Read()) 151 { 152 string result = reader.GetString(0); 153 hasAccess = result == "True"; 154 } 155 } 156 } 157 return hasAccess; 158 } 159 } 160 161 162
Error executing template "Designs/Swift/Paragraph/Swift_ProductComponentSlider.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_64db90efeb7740c59c0b28ca56596a46.Execute() in D:\dynamicweb.net\Solutions\Altex Holding\altexrtc.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductComponentSlider.cshtml:line 130
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 string layout = Model.Item.GetRawValueString("Layout") == "slider" ? "ProductSliderComponent" : "ProductGridComponent"; 7 string lazyHeight = Model.Item.GetBoolean("SetMinHeightForLazyLoading") ? "min-height: 360px" : ""; 8 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 9 string title = Model.Item.GetString("Title"); 10 11 //Link generation 12 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 13 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : ""; 14 pageId = pageId == "" ? servicePageByNavigationTag : pageId; 15 16 string url = "/Default.aspx?ID=" + pageId; 17 18 if (Pageview.IsVisualEditorMode) 19 { 20 url += "&VisualEdit=True"; 21 } 22 23 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 24 if (isLazyLoadingForProductInfoEnabled) 25 { 26 url += "&getproductinfo=true"; 27 } 28 29 url += $"&ProductListPartial={layout}"; //Use this to render either a slider or a grid 30 31 32 bool productViewModelFound = false; 33 ProductViewModel product = new ProductViewModel(); 34 35 ProductViewModelSettings productSetting = new ProductViewModelSettings 36 { 37 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 38 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 39 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 40 ShopId = Pageview.Area.EcomShopId 41 }; 42 43 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 44 { 45 productViewModelFound = true; 46 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 47 } 48 if (Pageview.IsVisualEditorMode && !productViewModelFound) 49 { 50 if (Pageview.Item["DummyProduct"] != null) 51 { 52 productViewModelFound = true; 53 string dummyProductId = ""; 54 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 55 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 56 if (productList.Products != null) 57 { 58 foreach (var p in productList.Products) { dummyProductId = p.Id; } 59 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 60 product = dummyProduct; 61 } 62 else 63 { 64 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 65 } 66 } 67 else if (Pageview.Item["DummyProduct"] == null) 68 { 69 productViewModelFound = true; 70 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 71 } 72 } 73 74 //Source type 75 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 76 IList<string> relateFromProductIds = new List<string> { }; 77 IList<string> relateFromGroupIds = new List<string> { }; 78 79 ProductListViewModel relateToViewModel = Model.Item.GetValue<ProductListViewModel>("RelateTo"); 80 81 //--- PRODUCTS --- 82 if (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected") 83 { 84 if (relateToViewModel?.Products != null) { 85 foreach (var fromProduct in relateToViewModel.Products) 86 { 87 var productId = fromProduct.Id; 88 relateFromProductIds.Add(productId); 89 } 90 } 91 } 92 93 //--- GROUPS --- 94 if (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest" || sourceType == "custom") 95 { 96 var groupsToRelateTo = Model.Item.GetString("RelateTo").Split(',').ToList(); 97 98 foreach (var fromGroup in groupsToRelateTo) 99 { 100 var groupId = fromGroup.Length > 2 ? fromGroup.Remove(0, 2) : fromGroup; 101 102 if (!fromGroup.Contains("p_")) { 103 relateFromGroupIds.Add(groupId); 104 } 105 } 106 107 if (relateToViewModel?.Products != null) { 108 foreach (var fromProduct in relateToViewModel.Products) 109 { 110 var groupId = fromProduct.PrimaryOrDefaultGroup.Id; 111 relateFromGroupIds.Add(groupId); 112 } 113 } 114 } 115 116 117 //Create group id collection and products id collection strings 118 string productIds = relateFromProductIds.Count > 0 ? string.Join(",", relateFromProductIds) : ""; 119 string groupIds = relateFromGroupIds.Count > 0 ? string.Join(",", relateFromGroupIds) : ""; 120 121 if (productViewModelFound) 122 { 123 if (string.IsNullOrEmpty(productIds) && (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected" || sourceType == "custom")) 124 { 125 productIds = product.Id; 126 } 127 128 if (string.IsNullOrEmpty(groupIds) && (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest")) 129 { 130 groupIds = product.PrimaryOrDefaultGroup.Id; 131 } 132 } 133 } 134 135 136 @*Container element for the request*@ 137 @if (!string.IsNullOrEmpty(productIds) || !string.IsNullOrEmpty(groupIds) || (string.IsNullOrEmpty(productIds) && string.IsNullOrEmpty(groupIds) && productViewModelFound == false)) 138 { 139 <form method="post" action="@url" id="ComponentSliderProductsForm_@Model.ID" data-response-target-element="ComponentSliderProducts_@Model.ID" data-preloader="inline" data-update-url="false" class="item_@Model.Item.SystemName.ToLower()"> 140 <input type="hidden" name="ParagraphId" value="@Model.ID" /> 141 <input type="hidden" name="SortOrder" value="DESC"> 142 143 @if (!string.IsNullOrEmpty(groupIds)) 144 { 145 <input type="hidden" name="GroupId" value="@groupIds" /> 146 } 147 @if (sourceType != "frequently" && !string.IsNullOrEmpty(productIds)) 148 { 149 <input type="hidden" name="MainProductId" value="@productIds" /> 150 } 151 152 @if (Model.Item.GetInt32("ProductsCount") != 0) 153 { 154 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 155 } 156 157 @if (sourceType == "variants") 158 { 159 <input type="hidden" name="isVariant" value="true"> 160 } 161 @if (sourceType == "most-sold") 162 { 163 <input type="hidden" name="SortBy" value="OrderCount"> 164 } 165 @if (sourceType == "trending") 166 { 167 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 168 } 169 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 170 { 171 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 172 } 173 @if (sourceType == "latest") 174 { 175 <input type="hidden" name="SortBy" value="Created"> 176 } 177 </form> 178 179 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 180 <script type="module"> 181 swift.AssetLoader.Load('Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 182 </script> 183 184 <div class="w-100 h-100@(theme)"> 185 <h5 class="h5">@title</h5> 186 <div id="ComponentSliderProducts_@Model.ID" class="h-100" style="@lazyHeight"></div> 187 </div> 188 189 <script type="module"> 190 const productSliderContainer = document.querySelector("#ComponentSliderProducts_@Model.ID"); 191 const productSliderForm = document.querySelector("#ComponentSliderProductsForm_@Model.ID"); 192 193 swift.PageUpdater.Update(productSliderForm); 194 productSliderForm.addEventListener("updated.swift.pageupdater", function(e){ 195 if (e.detail.html === "") { 196 productSliderContainer.closest("[data-col-size]").classList.add("d-none"); 197 } 198 }); 199 </script> 200 } 201 else if (Pageview.IsVisualEditorMode == true) 202 { 203 <div class="alert alert-dark" role="alert"> 204 <span>@Translate("Product component slider: The slider will be rendered here, if there is anything to show")</span> 205 </div> 206 } 207

Catalog 2023-2024

Solutii complete pentru mediul tau de lucru

Prin click pe „Accept toate”, sunteti de acord ca putem colecta informatii privind navigarea pe site, in diverse scopuri, inclusiv: funcționalitate, statistici și marketing.