Error executing template "Designs/Swift/eCom/ProductCatalog/ProductViewDetail.cshtml" System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Dynamicweb.Data.DatabaseConnectionProvider.CreateConnection(Boolean open) at Dynamicweb.Data.Database.CreateConnection() at Dynamicweb.Data.Database.CreateDataReader(CommandBuilder commandBuilder, IDbConnection connection, IDbTransaction transaction, Int32 commandTimeout) at Dynamicweb.Ecommerce.Products.DetailRepository.GetInheritedDetailsBulk(List`1 productIds, String detailType, Boolean onlyDefault) at Dynamicweb.Ecommerce.Products.DetailService.GetPrimaryDetailsBulk(IEnumerable`1 productKeys, String detailType) at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetDefaultImage(MediaViewModelSettings settings, String productId, String languageId, String variantId, Lazy`1 productImages, Lazy`1 details) at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetDefaultImage(MediaViewModelSettings settings, Product product, Lazy`1 productImages, Lazy`1 details) at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__62() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at CompiledRazorTemplates.Dynamic.RazorEngine_7cfb1c214419429693590bb1a1d1c049.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\eCom\ProductCatalog\ProductViewDetail.cshtml:line 9 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:00000000-0000-0000-0000-000000000000 Error Number:53,State:0,Class:20
1 @inherits ViewModelTemplate<ProductViewModel> 2 @using Dynamicweb.Rendering 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 @using Dynamicweb.Core 5 6 @{ 7 string metaDescription = string.IsNullOrEmpty(Model.MetaDescription) ? Model.Name : Model.MetaDescription; 8 9 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Model.DefaultImage.Value}\">"); 10 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{Model.Name}\">"); 11 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{metaDescription}\">"); 12 13 Pageview.Meta.AddTag("twitter:image", Model.DefaultImage.Value); 14 Pageview.Meta.AddTag("twitter:image:alt", Model.Name); 15 Pageview.Meta.AddTag("twitter:description", metaDescription); 16 } 17 18 @{ 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 Dynamicweb.Context.Current.Items["ProductDetails"] = Model; 22 } 23 else 24 { 25 Dynamicweb.Context.Current.Items.Add("ProductDetails", Model); 26 } 27 28 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 29 if (isLazyLoadingForProductInfoEnabled) 30 { 31 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 32 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 33 bool hasVariantId = !string.IsNullOrEmpty(Model.VariantId); 34 string variantIdParam = hasVariantId ? $"/{Model.VariantId}" : ""; 35 string priceFilledProperties = $"Price,PriceFormatted{(showPricesWithVat == "false" && !neverShowVat ? ",PriceWithVat,PriceWithVatFormatted" : "")}"; 36 string productInfoFeed = $@"/dwapi/ecommerce/products/{Model.Id}{variantIdParam} 37 ?UserId={Converter.ToString(Pageview.User?.ID)} 38 &LanguageId={Pageview.Area.EcomLanguageId}&CurrencyCode={Pageview.Area.EcomCurrencyId}&CountryCode={Pageview.Area.EcomCountryCode}&ShopId={Pageview.Area.EcomShopId} 39 &FilledProperties=Id,Price,PriceBeforeDiscount,StockLevel,VariantInfo,NeverOutOfstock,Prices 40 &PriceSettings.ShowPricesWithVat={Pageview.Area.EcomPricesWithVat} 41 &PriceSettings.FilledProperties={priceFilledProperties} 42 &getproductinfo=true"; 43 Dynamicweb.Context.Current.Items["ProductInfoFeed"] = productInfoFeed; 44 45 <script type="module"> 46 swift.LiveProductInfo.init(); 47 </script> 48 } 49 } 50 51 <script> 52 gtag("event", "view_item", { 53 currency: "@Model.Price.CurrencyCode", 54 value: @PriceViewModelExtensions.ToStringInvariant(Model.Price), 55 items: [ 56 { 57 item_id: "@Model.Number", 58 item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(Model.Name)", 59 currency: "@Model.Price.CurrencyCode", 60 price: @PriceViewModelExtensions.ToStringInvariant(Model.Price) 61 } 62 ] 63 }); 64 </script> 65 66 <script> 67 window.addEventListener('load', function (event) { 68 swift.Video.init(); 69 }); 70 </script> 71
Error executing template "/Designs/Swift/Paragraph/Swift_BreadcrumbNavigation_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_05862a0676de455da9300fba172e2c91.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_BreadcrumbNavigation_Custom.cshtml:line 17 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.Frontend.Navigation 3 @using Dynamicweb.Core 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Content 6 @using Dynamicweb.Frontend 7 @using System 8 9 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 10 11 @{ 12 ProductViewModel product = new ProductViewModel(); 13 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 14 { 15 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 16 } 17 string contentPageLink = Converter.ToString(Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.ProductGroupFieldValues.GetProductGroupFieldValue("ProductContentPage").Value); 18 int contentPageId = Converter.ToInt32(contentPageLink.Split('=').Last()); 19 20 if (contentPageId != 0) 21 { 22 IEnumerable<Dynamicweb.Content.Page> contentPageAncestors = Dynamicweb.Services.Pages.GetAncestors(contentPageId, true); 23 24 List<Dynamicweb.Content.Page> breadcrumbs = new List<Dynamicweb.Content.Page>(); 25 for (int i = contentPageAncestors.Count() - 1; i > 0; i--) 26 { 27 var page = contentPageAncestors.ElementAt(i); 28 if (page.ShowInSitemap) 29 { 30 breadcrumbs.Add(page); 31 } 32 else 33 { 34 break; 35 } 36 } 37 38 <ol class="breadcrumb small mb-0"> 39 @foreach (Dynamicweb.Content.Page page in breadcrumbs.Reverse<Dynamicweb.Content.Page>()) 40 { 41 string link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + page.ID); 42 <li class="breadcrumb-item"> 43 <a href="@link">@page.MenuText</a> 44 </li> 45 } 46 </ol> 47 } 48 } 49 50 51
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsImage_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26 at CompiledRazorTemplates.Dynamic.RazorEngine_cb54cb6cdc4941e0a93afe765fb5eccd.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsImage_Custom.cshtml:line 87 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 @using NLWI.Core.Factory 6 @using NLWI.Platforms.Dynamicweb9.Specs.Services 7 @using NORRIQ.CustomCode.Razor 8 @using Dynamicweb.Environment 9 @using Custom.Discounts.Services 10 11 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 12 13 @functions { 14 public ProductViewModel product { get; set; } = new ProductViewModel(); 15 public string galleryLayout { get; set; } 16 public string[] supportedImageFormats { get; set; } 17 public string[] supportedVideoFormats { get; set; } 18 public string[] supportedDocumentFormats { get; set; } 19 public string[] allSupportedFormats { get; set; } 20 21 public class RatioSettings 22 { 23 public string Ratio { get; set; } 24 public string CssClass { get; set; } 25 public string CssVariable { get; set; } 26 public string Fill { get; set; } 27 } 28 29 public RatioSettings GetRatioSettings(string size = "desktop") 30 { 31 var ratioSettings = new RatioSettings(); 32 33 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 34 ratio = ratio != "0" ? ratio : ""; 35 string cssClass = ratio != "" && ratio != "fill" ? " ratio" : ""; 36 string cssVariable = ratio != "" && ratio != "fill" ? "--bs-aspect-ratio: " + ratio : ""; 37 cssClass = ratio != "" && ratio == "fill" && size == "mobile" ? " ratio" : cssClass; 38 cssVariable = ratio != "" && ratio == "fill" && size == "mobile" ? "--bs-aspect-ratio: 66%" : cssVariable; 39 40 ratioSettings.Ratio = ratio; 41 ratioSettings.CssClass = cssClass; 42 ratioSettings.CssVariable = cssVariable; 43 ratioSettings.Fill = ratio == "fill" ? " h-100" : ""; 44 45 return ratioSettings; 46 } 47 } 48 49 @using NLWI.Platforms.Dynamicweb9.Specs.ViewModels 50 51 @functions { 52 string GetProductImage(ProductSpecifications specs) 53 { 54 string imageUrl = "/Files/Images/Perfion/default.png"; 55 56 if (specs.HasKey("Primærbillede")) 57 { 58 imageUrl = specs.GetByKey("Primærbillede").Value; 59 } 60 61 return imageUrl; 62 } 63 64 Dictionary<string, string> GetAllProductImages(ProductSpecifications specs) 65 { 66 Dictionary<string, string> images = new Dictionary<string, string>(); 67 68 foreach (var img in specs.GetByGroup("Billeder")) 69 { 70 if (!images.ContainsKey(img.Value) && img.Key != "Brandlogo") 71 { 72 images.Add(img.Value, img.Caption); 73 } 74 } 75 76 return images; 77 } 78 } 79 80 @{ 81 @* Get the product data *@ 82 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 83 { 84 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 85 } 86 87 var productSpecs = product.GetSpecifications(); 88 89 @* Supported formats *@ 90 supportedImageFormats = new string[] { ".jpg", ".jpeg", ".webp", ".png", ".gif", ".bmp", ".tiff" }; 91 supportedVideoFormats = new string[] { "youtu.be", "youtube", "vimeo", ".mp4", ".webm" }; 92 supportedDocumentFormats = new string[] { ".pdf", ".docx", ".xlsx", ".ppt", "pptx" }; 93 allSupportedFormats = supportedImageFormats.Concat(supportedVideoFormats).Concat(supportedDocumentFormats).ToArray(); 94 95 @* Collect the assets *@ 96 var selectedAssetCategories = Model.Item.GetRawValueString("ImageAssets").Split(',').ToList(); 97 bool includeImagePatternImages = Model.Item.GetBoolean("ImagePatternImages"); 98 99 @* Needed image data collection to support both DefaultImage, ImagePatterns and Image Assets *@ 100 string defaultImage = product.DefaultImage != null ? product.DefaultImage.Value : ""; 101 IEnumerable<MediaViewModel> assetsImages = product.AssetCategories.Where(x => selectedAssetCategories.Contains(x.SystemName)).SelectMany(x => x.Assets); 102 assetsImages = assetsImages.OrderByDescending(x => x.Value.Equals(defaultImage)); 103 IEnumerable<MediaViewModel> assetsList = new MediaViewModel[] { }; 104 105 assetsList = assetsList.Union(assetsImages); 106 assetsList = includeImagePatternImages ? assetsList.Union(product.ImagePatternImages) : assetsList; 107 assetsList = includeImagePatternImages && assetsList.Count() == 0 ? assetsList.Append(product.DefaultImage) : assetsList; 108 109 bool defaultImageFallback = Model.Item.GetBoolean("DefaultImageFallback"); 110 bool showOnlyPrimaryImage = Model.Item.GetBoolean("ShowOnlyPrimaryImage"); 111 112 int totalAssets = 0; 113 if (showOnlyPrimaryImage == false) 114 { 115 foreach (MediaViewModel asset in assetsList) 116 { 117 var assetValue = asset.Value.ToLower(); 118 foreach (string format in allSupportedFormats) 119 { 120 if (assetValue.Contains(format)) 121 { 122 totalAssets++; 123 } 124 } 125 } 126 } 127 128 if ((totalAssets == 0 && product.DefaultImage != null && selectedAssetCategories.Count() == 0) || (showOnlyPrimaryImage == true && product.DefaultImage != null)) 129 { 130 assetsList = new List<MediaViewModel>() { product.DefaultImage }; 131 totalAssets = 1; 132 } 133 134 @* Theme settings *@ 135 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 136 137 var badgeParms = new Dictionary<string, object>(); 138 badgeParms.Add("size", "h5"); 139 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 140 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 141 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 142 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 143 badgeParms.Add("campaignBadgesValues", Model.Item.GetRawValueString("CampaignBadges")); 144 145 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 146 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 147 DateTime createdDate = product.Created.Value; 148 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 149 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 150 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 151 152 @*CUSTOM*@ 153 var productDiscountInfo = Custom.Discounts.Services.DiscountInfoService.GetDiscountExtenderInfoByProductId(product.Id)?.Where(x => !string.IsNullOrEmpty(x.CampaignLabel)); 154 @*CUSTOM*@ 155 } 156 157 @* Get assets from selected categories or get all assets *@ 158 @if (totalAssets != 0) 159 { 160 int assetNumber = 0; 161 int thumbnailNumber = 0; 162 int modalAssetNumber = 0; 163 164 string featurePostFix = Pageview.AreaSettings.GetItem("CustomSettings").GetRawValueString("FeaturePostFix_Custom", ""); 165 166 <div class="h-100@(theme) position-relative"> 167 168 @if (productSpecs.HasKey("Ikon" + featurePostFix) || productDiscountInfo.Any()) 169 { 170 <div class="product-label"> 171 @foreach (var label in productSpecs.GetAllByKey("Ikon" + featurePostFix)) 172 { 173 var referenceSpecfication = label.GetReferenceSpecification(); 174 var txtcolor = "#ffffff"; 175 if (!string.IsNullOrEmpty(referenceSpecfication.GetByKey("LinkFarvekode").Value)) 176 { 177 txtcolor = referenceSpecfication.GetByKey("LinkFarvekode").Value; 178 } 179 if (referenceSpecfication.HasKey("LinkURL")) 180 { 181 <a href="@(referenceSpecfication.GetByKey("LinkURL").Value)" class="product-label-item" style="background-color:@(referenceSpecfication.GetByKey("Farvekode").Value);color:@txtcolor;"> 182 @referenceSpecfication.GetByKey("Label").Value 183 </a> 184 } 185 else 186 { 187 <span class="product-label-item" style="background-color:@(referenceSpecfication.GetByKey("Farvekode").Value);color:@txtcolor;"> 188 @referenceSpecfication.GetByKey("Label").Value 189 </span> 190 } 191 } 192 193 @*CUSTOM*@ 194 @if (productDiscountInfo != null) 195 { 196 foreach (var discount in productDiscountInfo) 197 { 198 <span class="product-label-item" style="background-color: @discount.CampaignLabelColor; color: @(!string.IsNullOrEmpty(discount.CampaignLabelTextColor) ? discount.CampaignLabelTextColor : "#ffffff");"> 199 @discount.CampaignLabel 200 </span> 201 } 202 } 203 @*CUSTOM*@ 204 </div> 205 } 206 207 <div id="SmallScreenImages_@Model.ID" class="carousel" data-bs-ride="carousel"> 208 <div class="carousel-inner h-100"> 209 @foreach (MediaViewModel asset in assetsList.OrderBy(a => a.DisplayName)) 210 { 211 var assetValue = asset.Value.ToLower(); 212 foreach (string format in allSupportedFormats) 213 { 214 if (assetValue.Contains(format)) 215 { 216 string activeSlide = assetNumber == 0 ? "active" : ""; 217 218 <div class="carousel-item @activeSlide" data-bs-interval="99999"> 219 @RenderAsset(asset, assetNumber, "mobile") 220 </div> 221 assetNumber++; 222 } 223 } 224 } 225 </div> 226 </div> 227 228 @if (totalAssets > 1) 229 { 230 <div id="SmallScreenImagesThumbnails_@Model.ID" class="grid gap-2 overflow-x-auto my-3 custom-thumbnails"> 231 @foreach (MediaViewModel asset in assetsList.OrderBy(a => a.DisplayName)) 232 { 233 var assetValue = asset.Value; 234 foreach (string format in allSupportedFormats) 235 { 236 if (assetValue.Contains(format)) 237 { 238 string imagePath = Dynamicweb.Context.Current.Server.UrlEncode(assetValue); 239 imagePath = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "https://img.youtube.com/vi/" + assetValue.Substring(assetValue.LastIndexOf('/') + 1) + "/default.jpg" : imagePath; 240 string imagePathThumb = !imagePath.Contains("youtube") ? $"/Admin/Public/GetImage.ashx?image={imagePath}&width=160&format=webp" : imagePath; 241 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 242 243 string videoId = assetValue.Substring(assetValue.LastIndexOf('/') + 1); 244 string vimeoJsClass = assetValue.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 245 246 bool isDocument = false; 247 foreach (string documentFormat in supportedDocumentFormats) 248 { 249 if (assetValue.Contains(documentFormat)) 250 { 251 isDocument = true; 252 } 253 } 254 255 string assetName = asset.Name; 256 assetName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 257 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 258 259 if (!isDocument) 260 { 261 <div class="ratio ratio-4x3 border outline-none" data-bs-target="#SmallScreenImages_@Model.ID" data-bs-slide-to="@thumbnailNumber" style="cursor: pointer"> 262 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 263 @foreach (string videoFormat in supportedVideoFormats) 264 { //Videos 265 if (assetValue.Contains(videoFormat)) 266 { 267 <div class="icon-3 position-absolute text-light" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> 268 } 269 } 270 </div> 271 <img src="@imagePathThumb" alt="@assetName" @assetTitle class="p-0 p-lg-1 @vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;"> 272 </div> 273 } 274 else 275 { 276 <a href="@assetValue" class="ratio ratio-4x3 border outline-none" style="cursor: pointer" download alt="@asset.Value"> 277 @if (asset.Value.Contains(".pdf")) 278 { 279 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 280 <div class="icon-3 position-absolute text-light" style="z-index: 1">@ReadFile(iconPath + "download.svg")</div> 281 </div> 282 <img src="@imagePathThumb" alt="@assetName" @assetTitle class="p-0 p-lg-1 mw-100 mh-100" style="object-fit: cover;"> 283 } 284 else 285 { 286 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 287 <div class="icon-3 position-absolute" style="z-index: 1">@ReadFile(iconPath + "file-text.svg")</div> 288 </div> 289 } 290 </a> 291 } 292 293 thumbnailNumber++; 294 } 295 } 296 } 297 </div> 298 } 299 300 @if (showBadges) 301 { 302 <div class="position-absolute top-0 left-0 p-2 p-lg-3"> 303 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 304 </div> 305 } 306 307 @* CAMPAIGN TEXT *@ 308 @if (productSpecs.HasKey("Kampagnetekst") && Model.Item.GetBoolean("CustomShowCampaign")) 309 { 310 @* Get the colors *@ 311 string backgroundColor = Model.Item.GetRawValueString("CustomBackgroundColor"); 312 string textColor = Model.Item.GetRawValueString("CustomTextColor"); 313 string linkColor = Model.Item.GetRawValueString("CustomLinkColor"); 314 315 <div class="card product-campaign clearfix" style="--background-color: @backgroundColor; --text-color: @textColor; --link-color: @linkColor;"> 316 <div class="card-block"> 317 @if (productSpecs.HasKey("Kampagnestart") && productSpecs.HasKey("Kampagneslut")) 318 { 319 var start = productSpecs.GetByKey("Kampagnestart").AsDate(); 320 var slut = productSpecs.GetByKey("Kampagneslut").AsDate(); 321 var nu = DateTime.Now; 322 323 if (start < nu && nu < slut) 324 { 325 <text> 326 @productSpecs.GetByKey("Kampagnetekst").Value 327 </text> 328 } 329 330 } 331 else 332 { 333 <text> 334 @productSpecs.GetByKey("Kampagnetekst").Value 335 </text> 336 } 337 </div> 338 </div> 339 } 340 </div> 341 342 @* Modal with slides *@ 343 <div class="modal fade" id="modal_@Model.ID" tabindex="-1" aria-labelledby="productDetailsGalleryModalTitle_@Model.ID" aria-hidden="true"> 344 <div class="modal-dialog modal-dialog-centered modal-xl"> 345 <div class="modal-content"> 346 <div class="modal-header visually-hidden"> 347 <h5 class="modal-title" id="productDetailsGalleryModalTitle_@Model.ID">@product.Title</h5> 348 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 349 </div> 350 <div class="modal-body p-2 p-lg-3 h-100"> 351 <div id="ModalCarousel_@Model.ID" class="carousel h-100" data-bs-ride="carousel"> 352 <div class="carousel-inner h-100"> 353 @foreach (MediaViewModel asset in assetsList.OrderBy(a => a.DisplayName)) 354 { 355 var assetValue = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 356 foreach (string format in allSupportedFormats) 357 { 358 if (assetValue.Contains(format)) 359 { 360 string imagePath = assetValue; 361 string activeSlide = modalAssetNumber == 0 ? "active" : ""; 362 363 var parms = new Dictionary<string, object>(); 364 parms.Add("cssClass", "d-block mw-100 mh-100 m-auto"); 365 parms.Add("fullwidth", true); 366 parms.Add("columns", Model.GridRowColumnCount); 367 368 <div class="carousel-item @activeSlide h-100" data-bs-interval="99999"> 369 @foreach (string imageFormat in supportedImageFormats) 370 { //Images 371 if (assetValue.Contains(imageFormat)) 372 { 373 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 374 } 375 } 376 377 @foreach (string videoFormat in supportedVideoFormats) 378 { //Videos 379 if (assetValue.Contains(videoFormat)) 380 { 381 @RenderVideoPlayer(asset, "modal") 382 } 383 } 384 </div> 385 386 modalAssetNumber++; 387 } 388 } 389 } 390 <button class="carousel-control-prev" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="prev"> 391 <span class="carousel-control-prev-icon" aria-hidden="true"></span> 392 <span class="visually-hidden">@Translate("Previous")</span> 393 </button> 394 <button class="carousel-control-next" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="next"> 395 <span class="carousel-control-next-icon" aria-hidden="true"></span> 396 <span class="visually-hidden">@Translate("Next")</span> 397 </button> 398 </div> 399 </div> 400 </div> 401 </div> 402 </div> 403 </div> 404 } 405 else if (Pageview.IsVisualEditorMode) 406 { 407 RatioSettings ratioSettings = GetRatioSettings("desktop"); 408 409 <div class="h-100 @theme"> 410 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)"> 411 <img src="~/Files/Images/missing_image.jpg" loading="lazy" decoding="async" class="mh-100 mw-100" style="object-fit: cover;" /> 412 </div> 413 </div> 414 } 415 416 @helper RenderAsset(MediaViewModel asset, int assetNumber, string size = "desktop") 417 { 418 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 419 string assetValue = asset.Value; 420 421 <div class="h-100 @(theme)"> 422 @foreach (string format in supportedImageFormats) 423 { //Images 424 if (assetValue.Contains(format)) 425 { 426 @RenderImage(asset, assetNumber, size) 427 } 428 } 429 @foreach (string format in supportedVideoFormats) 430 { //Videos 431 if (assetValue.Contains(format)) 432 { 433 if (Model.Item.GetString("OpenVideoInModal") == "true") 434 { 435 @RenderVideoScreendump(asset, assetNumber, size) 436 } 437 else 438 { 439 @RenderVideoPlayer(asset, size) 440 } 441 } 442 } 443 @foreach (string format in supportedDocumentFormats) 444 { //Documents 445 if (assetValue.Contains(format)) 446 { 447 @RenderDocument(asset, assetNumber, size) 448 } 449 } 450 </div> 451 } 452 453 @helper RenderImage(MediaViewModel asset, int number, string size = "desktop") 454 { 455 string productName = product.Name; 456 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 457 string imageLinkPath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 458 459 RatioSettings ratioSettings = GetRatioSettings(size); 460 461 var parms = new Dictionary<string, object>(); 462 parms.Add("alt", productName + asset.Keywords); 463 parms.Add("itemprop", "image"); 464 parms.Add("fullwidth", true); 465 parms.Add("columns", Model.GridRowColumnCount); 466 if (!string.IsNullOrEmpty(asset.DisplayName)) 467 { 468 parms.Add("title", asset.DisplayName); 469 } 470 471 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 472 { 473 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 474 } 475 else 476 { 477 parms.Add("cssClass", "mw-100 mh-100"); 478 } 479 480 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 481 <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"> 482 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 483 </div> 484 </a> 485 } 486 487 @helper RenderImage(string imagePath, int number, string size = "desktop") 488 { 489 string productName = product.Name; 490 string imageLinkPath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 491 492 RatioSettings ratioSettings = GetRatioSettings(size); 493 494 var parms = new Dictionary<string, object>(); 495 parms.Add("alt", productName); 496 parms.Add("itemprop", "image"); 497 parms.Add("fullwidth", true); 498 parms.Add("columns", Model.GridRowColumnCount); 499 500 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 501 { 502 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 503 } 504 else 505 { 506 parms.Add("cssClass", "mw-100 mh-100"); 507 } 508 509 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 510 <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"> 511 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 512 </div> 513 </a> 514 } 515 516 @helper RenderVideoScreendump(MediaViewModel asset, int number, string size = "desktop") 517 { 518 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 519 520 string videoScreendumpPath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : ""; 521 string videoId = videoScreendumpPath.Substring(videoScreendumpPath.LastIndexOf('/') + 1); 522 videoScreendumpPath = videoScreendumpPath.Contains("youtu.be") || videoScreendumpPath.Contains("youtube") ? "https://img.youtube.com/vi/" + videoId + "/maxresdefault.jpg" : videoScreendumpPath; 523 524 string vimeoJsClass = videoScreendumpPath.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 525 videoScreendumpPath = videoScreendumpPath.Contains("vimeo") ? "" : videoScreendumpPath; 526 527 string productName = product.Name; 528 productName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 529 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 530 531 RatioSettings ratioSettings = GetRatioSettings(size); 532 533 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable); cursor: pointer" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 534 <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"> 535 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> 536 <img src="@videoScreendumpPath" loading="lazy" decoding="async" alt="@productName" @assetTitle class="@vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;" /> 537 </div> 538 </div> 539 } 540 541 @helper RenderVideoPlayer(MediaViewModel asset, string size = "desktop") 542 { 543 string assetName = !string.IsNullOrEmpty(asset.DisplayName) ? asset.DisplayName : asset.Name; 544 string assetValue = asset.Value; 545 string videoId = asset.Value.Substring(asset.Value.LastIndexOf('/') + 1); 546 string type = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "youtube" : ""; 547 type = assetValue.Contains("vimeo") ? "vimeo" : type; 548 type = assetValue.Contains(".mp4") || assetValue.Contains(".webm") ? "selfhosted" : type; 549 550 string openInModal = Model.Item.GetString("OpenVideoInModal"); 551 bool autoPlay = Model.Item.GetBoolean("VideoAutoPlay"); 552 553 <div class="h-100" itemscope itemtype="https://schema.org/VideoObject"> 554 <span class="visually-hidden" itemprop="name">@assetName</span> 555 <span class="visually-hidden" itemprop="contentUrl">@asset.Value</span> 556 <span class="visually-hidden" itemprop="thumbnailUrl">@asset.Value</span> 557 558 @if (type != "selfhosted") 559 { 560 <div id="player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size" 561 class="plyr__video-embed" 562 data-plyr-provider="@(type)" 563 data-plyr-embed-id="@videoId" 564 style="--plyr-color-main: var(--swift-foreground-color); height: 100%"> 565 </div> 566 567 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/plyr.js"></script> 568 569 <script type="module"> 570 var player = new Plyr('#player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size', { 571 type: 'video', 572 youtube: { 573 noCookie: true, 574 showinfo: 0 575 }, 576 fullscreen: { 577 enabled: true, 578 iosNative: true, 579 } 580 }); 581 582 @if (autoPlay && openInModal == "false") { 583 <text> 584 player.config.autoplay = true; 585 player.config.muted = true; 586 player.config.volume = 0; 587 player.media.loop = true; 588 589 player.on('ready', function() { 590 if (player.config.autoplay === true) { 591 player.media.play(); 592 } 593 }); 594 </text> 595 } 596 597 @if (openInModal == "true") { 598 <text> 599 var productDetailsGalleryModal = document.querySelector('#modal_@Model.ID') 600 productDetailsGalleryModal.addEventListener('hidden.bs.modal', function (event) { 601 player.media.pause(); 602 }) 603 </text> 604 } 605 </script> 606 } 607 else 608 { 609 string autoPlayAttributes = (autoPlay && openInModal == "false") ? "loop autoplay muted playsinline" : ""; 610 string videoType = Path.GetExtension(assetValue).ToLower(); 611 612 <video preload="auto" @autoPlayAttributes class="h-100 w-100" style="object-fit: cover;"> 613 <source src="@assetValue" type="video/@videoType.Replace(".", "")"> 614 </video> 615 } 616 </div> 617 } 618 619 @helper RenderDocument(MediaViewModel asset, int number, string size = "desktop") 620 { 621 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 622 623 string productName = product.Name; 624 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 625 string imageLinkPath = imagePath; 626 627 RatioSettings ratioSettings = GetRatioSettings(size); 628 629 var parms = new Dictionary<string, object>(); 630 parms.Add("alt", productName + asset.Keywords); 631 parms.Add("itemprop", "image"); 632 parms.Add("fullwidth", true); 633 parms.Add("columns", Model.GridRowColumnCount); 634 if (!string.IsNullOrEmpty(asset.DisplayName)) 635 { 636 parms.Add("title", asset.DisplayName); 637 } 638 639 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 640 { 641 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 642 } 643 else 644 { 645 parms.Add("cssClass", "mw-100 mh-100"); 646 } 647 648 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" download alt="@Translate("Download")"> 649 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 650 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "download.svg")</div> 651 @if (asset.Value.Contains(".pdf")) 652 { 653 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 654 } 655 </div> 656 </a> 657 } 658
Error executing template "Designs/Swift/Paragraph/Swift_ProductPrice_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_0a1fec4e77e04d3c9f1ab24b1726ef73.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice_Custom.cshtml:line 76 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.Ecommerce.CustomerExperienceCenter.Favorites 4 @using System.Linq 5 @using Dynamicweb.Core 6 @using NLWI.Core.Factory 7 @using NLWI.Platforms.Dynamicweb9.Specs.ViewModels 8 @using NLWI.Platforms.Dynamicweb9.Specs.Services 9 @using NORRIQ.CustomCode.Razor 10 @using NORRIQ.CustomCode.StockLocations 11 @using System.Text; 12 @using System.Web; 13 @using System.Globalization 14 15 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 16 17 @{ 18 ProductViewModel product = new ProductViewModel(); 19 20 ProductViewModelSettings productSetting = new ProductViewModelSettings 21 { 22 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 23 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 24 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 25 ShopId = Pageview.Area.EcomShopId 26 }; 27 28 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 29 { 30 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 31 } 32 else if (Pageview.Item["DummyProduct"] != null) 33 { 34 35 string dummyProductId = ""; 36 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 37 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 38 if (productList.Products != null) 39 { 40 foreach (var p in productList.Products) { dummyProductId = p.Id; } 41 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 42 product = dummyProduct; 43 } 44 else 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 } 49 else if (Pageview.Item["DummyProduct"] == null) 50 { 51 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 52 } 53 54 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 55 bool anonymousUser = Pageview.User == null; 56 bool isErpConnectionDown = false;//ynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 57 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 58 59 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 60 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 61 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 62 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 63 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 64 65 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 66 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 67 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 68 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 69 70 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 71 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 72 string order = layout == "horizontal" ? string.Empty : "order-2"; 73 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "px-2 theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 74 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 75 76 var disablePrice = product.ProductFields.ContainsKey("Custom_DisablePrice") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePrice"].Value) : false; //CUSTOM 77 } 78 79 @if (!hidePrice && product.Id != null && !disablePrice) //CUSTOM 80 { 81 string showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 82 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 83 84 string priceMin = ""; 85 string priceMax = ""; 86 87 string liveInfoClass = ""; 88 string productInfoFeed = ""; 89 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 90 if (isLazyLoadingForProductInfoEnabled) 91 { 92 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 93 { 94 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 95 if (!string.IsNullOrEmpty(productInfoFeed)) 96 { 97 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 98 } 99 } 100 liveInfoClass = "js-live-info"; 101 } 102 103 FieldValueViewModel fieldValueViewModel = null; 104 product.ProductFields.TryGetValue("SchillingShowBeforePrice", out fieldValueViewModel); 105 bool showBeforePrice = fieldValueViewModel != null ? Converter.ToBoolean(fieldValueViewModel.Value) : false; 106 107 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" @productInfoFeed> 108 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 109 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 110 111 @if (showPricesWithVat == "false" && !neverShowVat) 112 { 113 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 114 { 115 <span itemprop="price" content="" class="d-none"></span> 116 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 117 } 118 else 119 { 120 string beforePrice = product.PriceBeforeDiscount.PriceWithoutVatFormatted; 121 string informativePrice = product.PriceInformative.PriceWithoutVatFormatted; 122 123 <span itemprop="price" content="@product.Price.PriceWithoutVat.ToString("0.00", CultureInfo.InvariantCulture)" class="d-none"></span> 124 if (product.Price.Price != product.PriceBeforeDiscount.Price) 125 { 126 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 127 } 128 else if (product.PriceInformative.Price > 0) 129 { 130 <span class="text-decoration-line-through opacity-75 @order">@informativePrice</span> 131 } 132 } 133 } 134 else 135 { 136 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 137 { 138 <span itemprop="price" content="" class="d-none"></span> 139 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 140 } 141 else 142 { 143 string beforePrice = product.PriceBeforeDiscount.PriceFormatted; 144 string informativePrice = product.PriceInformative.PriceFormatted; 145 146 <span itemprop="price" content="@product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture)" class="d-none"></span> 147 148 if (product.Price.Price != product.PriceBeforeDiscount.Price) 149 { 150 <span class="text-decoration-line-through opacity-75 @order"> 151 <span class="text-price">@beforePrice</span> 152 </span> 153 } 154 else if (product.PriceInformative.Price > 0) 155 { 156 <span class="text-decoration-line-through opacity-75 @order"> 157 <span class="text-price">@informativePrice</span> 158 </span> 159 } 160 } 161 } 162 163 @if (showPricesWithVat == "false" && !neverShowVat) 164 { 165 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 166 { 167 <span class="text-price js-text-price"> 168 <div class="spinner-border" role="status"></div> 169 </span> 170 } 171 else 172 { 173 string price = product.Price.PriceWithoutVatFormatted; 174 if (product?.VariantInfo?.VariantInfo != null) 175 { 176 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 177 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 178 } 179 if (priceMin != priceMax) 180 { 181 price = priceMin + " - " + priceMax; 182 } 183 <span class="@theme"> 184 <span class="text-price">@price</span> 185 </span> 186 } 187 } 188 else 189 { 190 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 191 { 192 <span class="text-price js-text-price"> 193 <div class="spinner-border" role="status"></div> 194 </span> 195 } 196 else 197 { 198 string price = product.Price.PriceFormatted; 199 if (product?.VariantInfo?.VariantInfo != null) 200 { 201 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 202 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 203 } 204 if (priceMin != priceMax) 205 { 206 price = priceMin + " - " + priceMax; 207 } 208 <span class="@theme"> 209 <span class="text-price">@price</span> 210 </span> 211 } 212 } 213 214 @* Stock state for Schema.org, start *@ 215 @{ 216 Uri url = Dynamicweb.Context.Current.Request.Url; 217 } 218 219 @{ 220 // Custom: ViaBill integration 221 if (Model.Item.GetBoolean("CustomActivateViaBill") && showPricesWithVat != "false") 222 { 223 <div class="viabill-pricetag" 224 data-view="product" 225 data-price="@product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture)" 226 data-currency="@Dynamicweb.Ecommerce.Common.Context.Currency.Code" 227 data-dynamic-price-trigger-delay="@Model.Item.GetInt32("CustomViaBillPriceDelay")"></div> 228 @Model.Item.GetRawValueString("CustomViaBillScript") 229 } 230 231 // Custom: Anyday integration 232 if (Model.Item.GetBoolean("CustomActivateAnyday") && !String.IsNullOrEmpty(Model.Item.GetRawValueString("CustomAnydayToken")) && showPricesWithVat != "false") 233 { 234 var locale = Dynamicweb.Frontend.PageView.Current().Area.CultureInfo.ToString(); 235 <anyday-price-widget theme="@Model.Item.GetRawValueString("CustomAnydayTheme")" 236 currency="@product.Price.CurrencyCode" 237 price="@product.Price.Price" 238 price-format-locale="@locale" 239 locale="@locale" 240 token="@Model.Item.GetRawValueString("CustomAnydayToken")" 241 fully-clickable="true" 242 debug="info"> 243 </anyday-price-widget> 244 245 @Model.Item.GetRawValueString("CustomAnydayScript") 246 } 247 } 248 249 250 <link itemprop="url" href="@url"> 251 252 @{ 253 bool IsNeverOutOfStock = product.NeverOutOfstock; 254 } 255 256 @if (IsNeverOutOfStock) 257 { 258 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 259 } 260 else 261 { 262 if (product.StockLevel > 0) 263 { 264 <span itemprop="availability" class="d-none">InStock</span> 265 } 266 else 267 { 268 <span itemprop="availability" class="d-none">OutOfStock</span> 269 } 270 } 271 @* Stock state for Schema.org, stop *@ 272 273 </div> 274 275 @if (showPricesWithVat == "false" && !neverShowVat) 276 { 277 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 278 { 279 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate(" Incl. VAT")"></small> 280 } 281 else 282 { 283 string price = product.Price.PriceWithVatFormatted; 284 if (product?.VariantInfo?.VariantInfo != null) 285 { 286 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 287 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 288 } 289 if (priceMin != priceMax) 290 { 291 price = priceMin + " - " + priceMax; 292 } 293 <small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small> 294 } 295 } 296 </div> 297 } 298 else if (Pageview.IsVisualEditorMode) 299 { 300 <div class="alert alert-dark m-0" role="alert"> 301 <span>@Translate("No products available")</span> 302 </div> 303 } 304
Error executing template "Designs/Swift/Paragraph/Swift_ProductBrandImage_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at CompiledRazorTemplates.Dynamic.RazorEngine_f75d03da4c9c43a8959b655d5aa88f3b.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductBrandImage_Custom.cshtml:line 49 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.Ecommerce.CustomerExperienceCenter.Favorites 4 @using ProductExtensions = NORRIQ.CustomCode.Razor.ProductViewModelExtensions; 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.Common8.Factory 7 @using System.Web 8 9 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 10 11 @{ 12 ProductViewModel product = new ProductViewModel(); 13 14 ProductViewModelSettings productSetting = new ProductViewModelSettings 15 { 16 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 17 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 18 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 19 ShopId = Pageview.Area.EcomShopId 20 }; 21 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 else if (Pageview.Item["DummyProduct"] != null) 27 { 28 string dummyProductId = ""; 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 if (productList.Products != null) 32 { 33 foreach (var p in productList.Products) { dummyProductId = p.Id; } 34 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 35 product = dummyProduct; 36 } 37 else 38 { 39 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 40 } 41 } 42 else if (Pageview.Item["DummyProduct"] == null) 43 { 44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 45 } 46 47 //Using old norriq code, is specificationService is removed from the project, change where we get the brand logo from 48 var specificationService = ObjectFactory.GetInstance<ProductSpecificationService>(); 49 var specs = specificationService.GetProductSpecifications(ProductExtensions.GetAutoId(product)); 50 51 string imagePath = specs.HasKey("Brandlogo") ? specs.GetByKey("Brandlogo").Value : ""; 52 imagePath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 53 54 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 55 ratio = ratio != "0" ? ratio : ""; 56 string ratioCssClass = ratio != "" ? " ratio" : ""; 57 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : ""; 58 59 string width = Model.Item.GetRawValueString("Width", "auto"); 60 int smallImageSize = 640; 61 int largeImageSize = width == "auto" ? 1280 : Convert.ToInt32(width); 62 63 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + imagePath + "&format=webp"; 64 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 65 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 66 } 67 68 @if (product.Id != null) 69 { 70 string fullWidth = width == "auto" ? "w-100" : ""; 71 string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : "style=\"min-width: 60px\""; 72 if (!string.IsNullOrEmpty(imagePath)) 73 { 74 <div class="h-100 @fullWidth position-relative item_@Model.Item.SystemName.ToLower()" @customWidth> 75 <div class="ratio" style="@(ratioVariable)"> 76 <div class="d-flex justify-content-center align-items-center"> 77 <img id="brandlogo" 78 srcset=" 79 @imagePathXs @(smallImageSize)w, 80 @imagePathS @(largeImageSize)w" 81 sizes="(min-width: 992px) 33vw, 50vw" 82 src="@imagePathFallBack" 83 loading="lazy" 84 decoding="async" 85 class="h-100 w-100" 86 style="object-fit: contain;" 87 alt="@HttpUtility.HtmlAttributeEncode(specs.HasKey("Brandlogo") ? specs.GetByKey("Brandlogo").Caption : "")"> 88 </div> 89 </div> 90 </div> 91 } 92 } 93 else if (Pageview.IsVisualEditorMode) 94 { 95 <div class="alert alert-dark m-0">@Translate("No products available")</div> 96 } 97
Error executing template "Designs/Swift/Paragraph/Swift_ProductLeasingButton_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at CompiledRazorTemplates.Dynamic.RazorEngine_2bd57417782c45bfab1a6d26844ba4a4.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductLeasingButton_Custom.cshtml:line 51 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.Ecommerce.CustomerExperienceCenter.Favorites 4 @using ProductExtensions = NORRIQ.CustomCode.Razor.ProductViewModelExtensions; 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.Common8.Factory 7 @using NORRIQ.CustomCode.Pricing 8 @using NORRIQ.CustomCode.Razor 9 @using System.Web 10 11 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 12 13 @{ 14 ProductViewModel product = new ProductViewModel(); 15 16 ProductViewModelSettings productSetting = new ProductViewModelSettings 17 { 18 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 19 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 20 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 21 ShopId = Pageview.Area.EcomShopId 22 }; 23 24 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 25 { 26 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 27 } 28 else if (Pageview.Item["DummyProduct"] != null) 29 { 30 string dummyProductId = ""; 31 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 32 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 33 if (productList.Products != null) 34 { 35 foreach (var p in productList.Products) { dummyProductId = p.Id; } 36 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 37 product = dummyProduct; 38 } 39 else 40 { 41 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 42 } 43 } 44 else if (Pageview.Item["DummyProduct"] == null) 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 49 //Using old norriq code, is specificationService is removed from the project, change where we get the data from 50 var specificationService = ObjectFactory.GetInstance<ProductSpecificationService>(); 51 var productSpecs = specificationService.GetProductSpecifications(ProductExtensions.GetAutoId(product)); 52 53 var showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 54 55 var productPrices = ObjectFactory.GetInstance<PriceService>().GetPrices(new[] { product.GetAutoId() }); 56 var productPrice = productPrices[product.GetAutoId()]; 57 58 var leasingPrice = product.GetLeasingPrice(productPrice); 59 var leasingAllowed = productSpecs.GetAllByKey("AllowLeasing").Any(a => a.Value.IsYes()) && showPricesWithVat == "false" && leasingPrice.HasValue; 60 } 61 62 @if (product.Id != null) 63 { 64 if (leasingAllowed) 65 { 66 <div class="d-flex flex-column"> 67 @if (Model.Item.GetBoolean("ShowLeasingPrice")) 68 { 69 <p class="mb-2 product-leasing-price">@Translate("Leasing 36 mnd:") <span class="fw-bold">@Dynamicweb.Ecommerce.Services.Currencies.FormatCurrency(Dynamicweb.Ecommerce.Common.Context.Currency, leasingPrice.Value, true)</span> @Translate("eksl. moms pr.mnd.")</p>} 70 @if (Model.Item.GetBoolean("ShowLeasingButton")) 71 { 72 <button class="btn btn-outline-primary" onclick="Form(this).addData('@HttpUtility.HtmlEncode(product.Name)', '@product.Id')" data-bs-toggle="modal" data-bs-target="#leasingModal">@Translate("Ansøg leasing (uforpligtende)")</button> 73 } 74 </div> 75 } 76 else if (Pageview.IsVisualEditorMode) 77 { 78 <div class="d-flex flex-column"> 79 @if (Model.Item.GetBoolean("ShowLeasingPrice")) 80 { 81 <p class="mb-2 product-leasing-price">@Translate("Leasing 36 mnd:") <span class="fw-bold">xxxx.xx</span> @Translate("eksl. moms pr.mnd.")</p> 82 } 83 @if (Model.Item.GetBoolean("ShowLeasingButton")) 84 { 85 <button class="btn btn-outline-primary">@Translate("Visual Editor Mode: Placeholder, no leasing on product")</button> 86 } 87 @if (!Model.Item.GetBoolean("ShowLeasingButton") && !Model.Item.GetBoolean("ShowLeasingPrice")) 88 { 89 <button class="btn btn-outline-primary">@Translate("Visual Editor Mode: Placeholder, neither price or button turned selected")</button> 90 } 91 </div> 92 } 93 } 94 else if (Pageview.IsVisualEditorMode) 95 { 96 <div class="alert alert-dark m-0">@Translate("No products available")</div> 97 } 98
Error executing template "Designs/Swift/Paragraph/Swift_ProductAddToCart_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_fa71a10feb2a41d8a2fd483878058cd9.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductAddToCart_Custom.cshtml:line 60 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.Ecommerce.CustomerExperienceCenter.Favorites 4 @using NLWI.Core.Factory 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.CustomCode.Razor 7 @using System.Web 8 @using System.Globalization 9 @using Dynamicweb.Core.Encoders 10 11 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 12 @* NOTE: Item contains unsupported itemfields: ShowAddToFavorites, ShowFavoritesSelectorMasterProduct, ShowQuantitySelector, ShowUnitsSelector, WhenVariantsExist, HideButtonText, Icon, ButtonSize, HideInventory, HideStockState, VariantSelectorServicePageId *@ 13 14 @{ 15 ProductViewModel product = new ProductViewModel(); 16 17 ProductViewModelSettings productSetting = new ProductViewModelSettings 18 { 19 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 20 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 21 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 22 ShopId = Pageview.Area.EcomShopId 23 }; 24 25 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 26 { 27 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 28 } 29 else if (Pageview.Item["DummyProduct"] != null) 30 { 31 32 string dummyProductId = ""; 33 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 34 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 35 if (productList.Products != null) 36 { 37 foreach (var p in productList.Products) { dummyProductId = p.Id; } 38 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 39 product = dummyProduct; 40 } 41 else 42 { 43 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 44 } 45 } 46 else if (Pageview.Item["DummyProduct"] == null) 47 { 48 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 49 } 50 51 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 52 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 53 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 54 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 55 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 56 57 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 58 bool anonymousUser = Pageview.User == null; 59 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; 60 hideAddToCart = product.VariantInfo.VariantInfo != null && Model.Item.GetBoolean("CustomHideVariantSelector") ? true : hideAddToCart; 61 hideAddToCart = product.ProductFields.ContainsKey("Custom_DisablePurchase") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePurchase"].Value) : hideAddToCart; //CUSTOM 62 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 63 bool hideFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("CustomHideFavoritesSelector")) ? Model.Item.GetBoolean("CustomHideFavoritesSelector") : false; 64 65 var favoriteParameters = new Dictionary<string, object>(); 66 if (!anonymousUser && !hideFavoritesSelector) 67 { 68 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 69 int defaultFavoriteListId = 0; 70 71 if (favoreiteLists.Count() == 1) 72 { 73 foreach (FavoriteList list in favoreiteLists) 74 { 75 defaultFavoriteListId = list.ListId; 76 } 77 } 78 79 favoriteParameters.Add("ListId", defaultFavoriteListId); 80 } 81 } 82 83 @if (!hideAddToCart && product.Id != null) 84 { 85 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 86 if (!url.Contains("LayoutTemplate")) 87 { 88 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 89 } 90 91 var productSpecificationService = ObjectFactory.GetInstance<IProductSpecificationService>(); 92 var productSpecs = productSpecificationService.GetProductSpecifications(product.GetAutoId()); 93 94 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 95 96 string minQty = product.PurchaseMinimumQuantity != 1 ? "min=\"" + product.PurchaseMinimumQuantity.ToString() + "\"" : "min=\"1\""; 97 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 98 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 99 string qtyValidCheck = stepQty != "1" ? "onkeyup=\"swift.Cart.QuantityValidate(event)\"" : ""; 100 101 string showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 102 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 103 104 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 105 <form method="post" action="@url" class="@fullWidth"> 106 <input type="hidden" name="redirect" value="false" /> 107 <input type="hidden" name="ProductId" value="@product.Id" /> 108 <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)" /> 109 <input type="hidden" name="ProductVariantName" value="@HtmlEncoder.HtmlEncode(product.VariantName)" /> 110 <input type="hidden" name="ProductCurrency" value="@productSetting.CurrencyCode" /> 111 <input type="hidden" name="ProductPrice" value="@(showPricesWithVat == "false" && !neverShowVat ? product.Price.PriceWithoutVat.ToString("0.00", CultureInfo.InvariantCulture) : product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture))" /> 112 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart_Custom"> 113 <input type="hidden" name="cartcmd" value="add" /> 114 115 <input type="hidden" class="js-product-id" value="@product.Id" /> 116 117 @if (!string.IsNullOrEmpty(product.VariantId)) 118 { 119 <input type="hidden" name="VariantId" value="@product.VariantId" /> 120 } 121 @if (!Model.Item.GetBoolean("CustomUseQuantitySelector")) 122 { 123 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" type="hidden"> 124 125 if (!productSpecs.GetByKey("Preorder").Value.IsYes()) 126 { 127 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary w-100 js-add-to-cart-button" title="@HttpUtility.HtmlEncode(Translate("Add to cart"))" id="AddToCartButton@(product.Id)">@Translate("Add to cart")</button> 128 } 129 else 130 { 131 <button type="button" class="btn btn-secondary w-100 text-uppercase" onclick="Form(this).addData('@HttpUtility.HtmlEncode(product.Name)', '@product.Id')" data-bs-toggle="modal" data-bs-target="#preorderModal"> 132 @Translate("Preorder") 133 </button> 134 } 135 } 136 else 137 { 138 <div class="input-group input-primary-button-group js-input-group d-flex flex-row flex-nowrap"> 139 <label for="Quantity_@(product.Id)" class="visually-hidden">@Translate("Quantity")</label> 140 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" step="@stepQty" @minQty class="form-control" style="max-width: 96px; min-width:64px;" type="number"> 141 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary flex-fill js-add-to-cart-button" title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)">@Translate("Add to cart")</button> 142 </div> 143 144 if (stepQty != "1") 145 { 146 <div class="invalid-feedback d-none"> 147 @Translate("Please select a quantity that is dividable by") @stepQty 148 </div> 149 } 150 } 151 </form> 152 @if (!anonymousUser && !hideFavoritesSelector) 153 { 154 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 155 } 156 </div> 157 } 158 else if (!anonymousUser && !hideFavoritesSelector) 159 { 160 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 161 <div class="flex-fill"> 162 @Translate("Add to favorites") @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 163 </div> 164 </div> 165 } 166 else if (Pageview.IsVisualEditorMode) 167 { 168 <div class="alert alert-dark m-0">@Translate("No products available")</div> 169 } 170
Error executing template "Designs/Swift/Paragraph/Swift_StockStatus.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_fc37fee338fc4068ab5379a3109587b9.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_StockStatus.cshtml:line 46 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 @* CUSTOMIZED SWIFT TEMPLATE *@ 5 6 @{ 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 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 20 } 21 else if (Pageview.Item["DummyProduct"] != null) 22 { 23 24 string dummyProductId = ""; 25 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 26 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 27 if (productList.Products != null) 28 { 29 foreach (var p in productList.Products) { dummyProductId = p.Id; } 30 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 31 product = dummyProduct; 32 } 33 else 34 { 35 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 36 } 37 } 38 else if (Pageview.Item["DummyProduct"] == null) 39 { 40 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 41 } 42 43 bool IsNeverOutOfStock = product.NeverOutOfstock; 44 var stockLocations = product.StockUnits; 45 46 var disableStock = product.ProductFields.ContainsKey("Custom_DisableStock") ? Convert.ToBoolean(product.ProductFields["Custom_DisableStock"].Value) : false; //CUSTOM 47 48 if (!Model.Item.GetBoolean("HideStockState") && !disableStock) //CUSTOM 49 { 50 if (!IsNeverOutOfStock) 51 { 52 var defaultOnlineStockLocationId = Model.Item.GetRawValueString("CustomDefaultStockLocation"); 53 54 //Custom: Build unified list of stock locations to display 55 var displayLocations = new List<(string Name, double Qty, bool IsDefault)>(); 56 57 //Custom: Check if default online stock location exists in the list 58 var hasDefaultLocation = !string.IsNullOrEmpty(defaultOnlineStockLocationId) && 59 stockLocations.Any(sl => sl.StockLocationId.ToString() == defaultOnlineStockLocationId); 60 61 //Custom: Add default online location first if not in the stock list 62 if (!string.IsNullOrEmpty(defaultOnlineStockLocationId) && !hasDefaultLocation) 63 { 64 var defaultOnlineStockLocation = Dynamicweb.Ecommerce.Services.StockService.GetStockLocation(Convert.ToInt32(defaultOnlineStockLocationId)); 65 var totalQty = stockLocations.Sum(sl => sl.StockLevel); 66 var defaultLocationName = defaultOnlineStockLocation.Name; 67 displayLocations.Add((defaultLocationName, totalQty, true)); 68 } 69 70 //Custom: Add existing stock locations 71 foreach (var stockLocation in stockLocations.OrderByDescending(location => defaultOnlineStockLocationId == location.StockLocationId.ToString())) 72 { 73 var locationName = stockLocation.StockLocationName; 74 var qty = stockLocation.StockLevel; 75 var isDefault = !string.IsNullOrEmpty(defaultOnlineStockLocationId) && 76 defaultOnlineStockLocationId == stockLocation.StockLocationId.ToString(); 77 78 //Custom: Sum inventory for all locations if online stock location 79 if (isDefault) 80 { 81 qty = stockLocations.Sum(sl => sl.StockLevel); 82 } 83 84 displayLocations.Add((locationName, qty, isDefault)); 85 } 86 87 <div class="mt-3 js-stock-state d-flex flex-column gap-2"> 88 <ul class="list-group"> 89 @foreach (var location in displayLocations) 90 { 91 <li class="list-group-item"> 92 <div class="product-stock-item d-flex justify-content-between"> 93 <span class="product-stock-location fs-7"> 94 @location.Name 95 </span> 96 <span class="product-stock-status fs-7"> 97 <span class="icon-stock @(location.Qty > 0 ? "icon-green" : "icon-red") position-relative"></span> 98 @(location.Qty > 0 ? Translate("label_in_Stock", "På lager") : Translate("label_not_in_stock", "Ikke på lager")) 99 </span> 100 </div> 101 </li> 102 } 103 </ul> 104 </div> 105 } 106 } 107 }
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsCampaignAccordion_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26 at CompiledRazorTemplates.Dynamic.RazorEngine_a80eb526f8a64fc3bbab1c93f1b9395d.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsCampaignAccordion_Custom.cshtml:line 49 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 NLWI.Core.Factory 4 @using NLWI.Platforms.Dynamicweb9.Specs.Services 5 @using NORRIQ.CustomCode.Razor 6 @using NORRIQ.CustomCode.Pricing 7 @using Custom.Discounts.Extenders 8 @using System.Web 9 10 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 11 12 @{ 13 ProductViewModel product = new ProductViewModel(); 14 15 ProductViewModelSettings productSetting = new ProductViewModelSettings 16 { 17 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 18 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 19 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 20 ShopId = Pageview.Area.EcomShopId 21 }; 22 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Item["DummyProduct"] != null) 28 { 29 30 string dummyProductId = ""; 31 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 32 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 33 if (productList.Products != null) 34 { 35 foreach (var p in productList.Products) { dummyProductId = p.Id; } 36 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 37 product = dummyProduct; 38 } 39 else 40 { 41 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 42 } 43 } 44 else if (Pageview.Item["DummyProduct"] == null) 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 49 var specs = product.GetSpecifications(); 50 var shopId = Pageview.Area.EcomShopId; 51 var language = Dynamicweb.Ecommerce.Services.Languages.GetLanguage(Pageview.Area.EcomLanguageId); 52 var featurePostFix = language.CountryCode == "DK" ? "" : language.Culture; 53 var backgroundColor = Model.Item.GetString("BackgroundColor"); 54 var textColor = Model.Item.GetString("TextColor"); 55 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 56 57 var productDiscountInfo = Custom.Discounts.Services.DiscountInfoService.GetDiscountExtenderInfoByProductId(product.Id)?.Where(x => !string.IsNullOrEmpty(x.CampaignLabel)); 58 59 @* CAMPAIGN TEXT *@ 60 if (specs.HasKey("Kampagnetekst") 61 || (productDiscountInfo != null && productDiscountInfo.Any())) 62 { 63 //Get the colors 64 string campaignBackgroundColor = Model.Item.GetRawValueString("CustomBackgroundColor"); 65 string campaignTextColor = Model.Item.GetRawValueString("CustomTextColor"); 66 string campaignLinkColor = Model.Item.GetRawValueString("CustomLinkColor"); 67 68 69 <div class="accordion mt-3" id="accordion"> 70 <div class="accordion-item" style="background-color: @campaignBackgroundColor; color: @campaignTextColor;"> 71 72 <h2 class="accordion-header" id="headingOne"> 73 <button class="accordion-button fw-bold collapsed" type="button" style="background-color: @campaignBackgroundColor; color: @campaignTextColor;" data-bs-toggle="collapse" data-bs-target="#collapseCampaign" aria-expanded="false" aria-controls="collapseCampaign"> 74 @Translate("Smartpage:Product.Details.Campaigns", "Kampagner") 75 </button> 76 </h2> 77 78 <div id="collapseCampaign" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 79 <div class="accordion-body d-flex justify-content-between flex-wrap"> 80 81 <div class="product-campaign clearfix" style="--background-color: @campaignBackgroundColor; --text-color: @campaignTextColor; --link-color: @campaignLinkColor;"> 82 @{ 83 if (specs.HasKey("Kampagnetekst")) 84 { 85 <div class="card-block"> 86 @if (specs.HasKey("Kampagnestart") && specs.HasKey("Kampagneslut")) 87 { 88 var start = specs.GetByKey("Kampagnestart").AsDate(); 89 var slut = specs.GetByKey("Kampagneslut").AsDate(); 90 var nu = DateTime.Now; 91 92 if (start < nu && nu < slut) 93 { 94 <text> 95 @specs.GetByKey("Kampagnetekst").Value 96 </text> 97 } 98 } 99 else 100 { 101 <text> 102 @specs.GetByKey("Kampagnetekst").Value 103 </text> 104 } 105 </div> 106 } 107 108 if (productDiscountInfo != null) 109 { 110 foreach (var discount in productDiscountInfo) 111 { 112 <div class="card-block"> 113 <h4>@discount.CampaignName</h4> 114 <p>@discount.CampaignDescription</p> 115 @if (!string.IsNullOrEmpty(discount.CampaignLink)) 116 { 117 <p><strong><a href="@discount.CampaignLink" title="@HttpUtility.HtmlAttributeEncode(discount.CampaignLinkText)">@discount.CampaignLinkText</a></strong></p> 118 } 119 </div> 120 } 121 } 122 } 123 </div> 124 </div> 125 </div> 126 </div> 127 </div> 128 } 129 else if (Pageview.IsVisualEditorMode) 130 { 131 <div class="alert alert-dark m-0">@Translate("Campaign info will be displayed here")</div> 132 } 133 } 134
Error executing template "Designs/Swift/Paragraph/CustomTradeIn.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26 at CompiledRazorTemplates.Dynamic.RazorEngine_b5f5c54bb0be4c6b93166c90aa90fe05.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\CustomTradeIn.cshtml:line 46 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 NLWI.Core.Factory 4 @using NORRIQ.CustomCode.Razor 5 6 @{ 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 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 20 } 21 else if (Pageview.Item["DummyProduct"] != null) 22 { 23 24 string dummyProductId = ""; 25 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 26 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 27 if (productList.Products != null) 28 { 29 foreach (var p in productList.Products) { dummyProductId = p.Id; } 30 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 31 product = dummyProduct; 32 } 33 else 34 { 35 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 36 } 37 } 38 else if (Pageview.Item["DummyProduct"] == null) 39 { 40 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 41 } 42 } 43 44 @if (product is object) 45 { 46 var specs = product.GetSpecifications(); 47 48 if (specs.GetByKey("LoopiaDisplayTradeInLink")?.Value == "true" || Pageview.IsVisualEditorMode) 49 { 50 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 51 var header = Model.Item.GetRawValueString("Header"); 52 var text = Model.Item.GetRawValueString("Text"); 53 var link = Model.Item.GetLink("Link"); 54 var linkText = Model.Item.GetRawValueString("LinkText"); 55 56 <div class="accordion mt-3 @theme" id="accordion"> 57 <div class="accordion-item"> 58 59 <h2 class="accordion-header" id="headingOne"> 60 <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTrade" aria-expanded="true" aria-controls="collapseOne"> 61 @header 62 </button> 63 </h2> 64 65 <div id="collapseTrade" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 66 <div class="accordion-body d-flex justify-content-between flex-wrap"> 67 <div class="p-2 fs-7"> 68 @text 69 <p> 70 <strong><a href="@(link?.Url + product.Number)">@linkText</a></strong> 71 </p> 72 </div> 73 </div> 74 </div> 75 </div> 76 </div> 77 } 78 } 79 else if (Pageview.IsVisualEditorMode) 80 { 81 <div class="alert alert-dark m-0">@Translate("Trade-in box will be displayed here")</div> 82 } 83
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsAccordion.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26 at CompiledRazorTemplates.Dynamic.RazorEngine_a2b8e9605e714951acb607d47cd9b680.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsAccordion.cshtml:line 46 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 @using NLWI.Core.Factory 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.CustomCode.Razor 7 @using NORRIQ.CustomCode.Pricing 8 9 @{ 10 ProductViewModel product = new ProductViewModel(); 11 12 ProductViewModelSettings productSetting = new ProductViewModelSettings 13 { 14 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 15 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 16 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 17 ShopId = Pageview.Area.EcomShopId 18 }; 19 20 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 21 { 22 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 23 } 24 else if (Pageview.Item["DummyProduct"] != null) 25 { 26 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.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 39 } 40 } 41 else if (Pageview.Item["DummyProduct"] == null) 42 { 43 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 44 } 45 46 var specs = product.GetSpecifications(); 47 var shopId = Pageview.Area.EcomShopId; 48 var ls = new Dynamicweb.Ecommerce.International.LanguageService(); 49 var language = ls.GetLanguage(Pageview.Area.EcomLanguageId); 50 var featurePostFix = language.CountryCode == "DK" ? "" : language.Culture; 51 var backgroundColor = Model.Item.GetString("BackgroundColor"); 52 var textColor = Model.Item.GetString("TextColor"); 53 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 54 55 <div class="accordion mt-3" id="accordion"> 56 @if (specs.GetAllByKey("Produktekspert" + featurePostFix).Any() && !Model.Item.GetBoolean("HideProductExperts")) 57 { 58 <div class="accordion-item"> 59 60 <h2 class="accordion-header" id="headingOne"> 61 <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne"> 62 <img src="@(iconPath)users.svg" class="me-2" /> 63 @Translate("Smartpage:Product.Details.Product experts", "Produkteksperter") 64 </button> 65 </h2> 66 67 <div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 68 <div class="accordion-body d-flex justify-content-between flex-wrap flex-column"> 69 70 71 @foreach (var expert in specs.GetAllByKey("Produktekspert" + featurePostFix)) 72 { 73 var referenceSpecfication = expert.GetReferenceSpecification(); 74 75 var image = "~/Files/Images/missing_image.jpg"; 76 foreach (var test in referenceSpecfication.GetAllAvailableKeys()) 77 { 78 if (referenceSpecfication.GetByKey(test).Value.Contains("Images/Perfion")) 79 { 80 image = referenceSpecfication.GetByKey(test).Value; 81 } 82 } 83 <div class="expert-container d-flex"> 84 <img src="/Admin/Public/GetImage.ashx?Image=@image&Width=60&Height=60&Crop=5&Compression=85" width="60" height="60" /> 85 <div class="info ms-2 fs-7"> 86 <strong>@referenceSpecfication.GetByKey("Value").Value</strong><br /> 87 <a href="mailto:@referenceSpecfication.GetByKey("Email").Value" class="link-primary">@referenceSpecfication.GetByKey("Email").Value</a><br /> 88 <span class="icon-phone"></span> 89 @referenceSpecfication.GetByKey("Telefonnr").Value<br /> 90 @if (referenceSpecfication.HasKey("Lokation")) 91 { 92 <span class="icon-map"></span> 93 @referenceSpecfication.GetByKey("Lokation").Value 94 }<br /><br /> 95 </div> 96 </div> 97 } 98 </div> 99 </div> 100 </div> 101 } 102 103 @if (specs.GetAllByKey("PDFbrochure").Any()) 104 { 105 <div class="accordion-item"> 106 107 <h2 class="accordion-header" id="headingTwo"> 108 <button class="accordion-button collapsed fw-bold" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> 109 <img src="@(iconPath)file.svg" class="me-2" /> 110 @Translate("Brochurer og tech. Info") 111 </button> 112 </h2> 113 114 <div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordion"> 115 <div class="accordion-body d-flex flex-column justify-content-between flex-wrap gap-2"> 116 @foreach (var pdfbrochure in specs.GetAllByKey("PDFbrochure")) 117 { 118 <div class="d-flex align-items-center"> 119 <img src="@(iconPath)file.svg" class="me-2" /> 120 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 121 @Translate("Produkt brochure") 122 </a> 123 </div> 124 } 125 @foreach (var pdfmanual in specs.GetAllByKey("PDFmanual")) 126 { 127 <div class="d-flex align-items-center"> 128 <img src="@(iconPath)file.svg" class="me-2" /> 129 <a href="@(pdfmanual.Value)" class="text-decoration-none" target="_blank"> 130 @Translate("Produkt manual") 131 </a> 132 </div> 133 } 134 @foreach (var pdfbrochure in specs.GetAllByKey("PDFreview")) 135 { 136 <div class="d-flex align-items-center"> 137 <img src="@(iconPath)file.svg" class="me-2" /> 138 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 139 @Translate("Produkt review") 140 </a> 141 </div> 142 } 143 </div> 144 </div> 145 </div> 146 } 147 148 149 @if (!Model.Item.GetBoolean("HideFactSheetLink")) 150 { 151 string sheetId = Model.Item.GetString("PerfionDatasheetId"); 152 153 <div class="accordion-item"> 154 <h2 class="accordion-header" id="headingTwo"> 155 <button class="accordion-button collapsed fw-bold noafter" type="button" onclick="window.open('/Handlers/DownloadPerfionDocument.ashx?number=@(product.Number)&reportId=@(sheetId)&language=@Translate("perfion_language","DAN")')" rel="nofollow" target="_blank"> 156 <img src="@(iconPath)download.svg" class="me-2" /> 157 @Translate("Smartpage:Product.Details.Printable fact sheet", "Printbar fakta side") 158 </button> 159 </h2> 160 </div> 161 } 162 </div> 163 }
Error executing template "/Designs/Swift/Paragraph/Swift_RelatedProducts_Custom.cshtml" System.ArgumentNullException: Value cannot be null. Parameter name: source at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at CompiledRazorTemplates.Dynamic.RazorEngine_99af50ce87cb4027bdb195f8068f3bcd.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_RelatedProducts_Custom.cshtml:line 33 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 NLWI.Core.Factory 4 @using NORRIQ.CustomCode.ProductRental.Services 5 6 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 7 8 @{ 9 ProductViewModel product = new ProductViewModel(); 10 11 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 12 { 13 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 14 } 15 16 if (product != null) 17 { 18 var rentalService = ObjectFactory.GetInstance<RentalProductService>(); 19 20 var uniqueId = Pageview.CurrentParagraph.ID.ToString(); 21 string title = Model?.Item?.GetString("Title") != null ? Model.Item.GetString("Title") : Translate("Products"); 22 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-6"); 23 bool hideTitle = Model.Item.GetBoolean("HideTitle"); 24 25 // Slider settings 26 int itemsInSlider = Model.Item.GetInt32("ItemsInSlider") == 0 ? 4 : Model.Item.GetInt32("ItemsInSlider"); 27 string enableControls = Model.Item.GetBoolean("EnableControls").ToString().ToLower(); 28 string enableIndcators = Model.Item.GetBoolean("EnableIndicators").ToString().ToLower(); 29 bool autoplay = Model.Item.GetBoolean("Autoplay"); 30 string interval = (autoplay) ? Model.Item.GetString("Interval", "5000") : "0"; 31 string enableAutoplay = autoplay.ToString().ToLower(); 32 33 bool isRental = rentalService.IsRentalProduct(product); 34 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 35 var productRelations = product.GetRelatedProducts(); 36 37 if (productRelations.Any()) 38 { 39 <div class="@(theme) related-products slider-wrapper-custom"> 40 @if (!hideTitle) 41 { 42 <h3 class="@titleFontSize text-center text-md-start">@title</h3> 43 } 44 45 <div class="related-products-slider js-slider" data-slider-items="@itemsInSlider"> 46 @foreach (var relatedProduct in productRelations) 47 { 48 var productParams = new Dictionary<string, object>() 49 { 50 { "product", relatedProduct } 51 }; 52 53 if (isRental) 54 { 55 @RenderPartial("Paragraph/Partials/RelatedRentalProduct.cshtml", Model, productParams); 56 } 57 else 58 { 59 @RenderPartial("Paragraph/Partials/RelatedProduct_Custom.cshtml", Model, productParams); 60 } 61 } 62 </div> 63 </div> 64 } 65 } 66 } 67
Error executing template "Designs/Swift/Paragraph/Swift_ProductSpecification_Custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47 at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26 at CompiledRazorTemplates.Dynamic.RazorEngine_15fb23da3af845eca7707b39cff5f23a.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductSpecification_Custom.cshtml:line 48 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 NLWI.Core.Factory 4 @using NORRIQ.CustomCode.Razor 5 @using System.Web 6 7 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 8 9 @{ 10 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 11 12 ProductViewModel product = new ProductViewModel(); 13 14 ProductViewModelSettings productSetting = new ProductViewModelSettings 15 { 16 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 17 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 18 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 19 ShopId = Pageview.Area.EcomShopId 20 }; 21 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 else if (Pageview.Item["DummyProduct"] != null) 27 { 28 29 string dummyProductId = ""; 30 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 31 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 32 if (productList.Products != null) 33 { 34 foreach (var p in productList.Products) { dummyProductId = p.Id; } 35 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 36 product = dummyProduct; 37 } 38 else 39 { 40 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 41 } 42 } 43 else if (Pageview.Item["DummyProduct"] == null) 44 { 45 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 46 } 47 48 var specs = product.GetSpecifications(); 49 } 50 51 52 @if (specs.GetByGroup("Specifikationer").Any()) 53 { 54 var prodSpecs = specs.GetByGroup("Specifikationer"); 55 bool hideTitle = Model.Item.GetBoolean("HideTitle"); 56 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-4"); 57 58 <div> 59 @if (!hideTitle) 60 { 61 <div class="text-start pb-2 pb-lg-4"> 62 <h2 class="@titleFontSize">@Model.Item.GetString("Title")</h2> 63 </div> 64 } 65 <div class="tab-pane" role="tabpanel" id="specs"> 66 <div class="table-responsive"> 67 <table class="table table-specs table-striped" style="table-layout: fixed"> 68 <tbody> 69 @foreach (var specKey in prodSpecs.GetAvailableKeys().Where(key => key != "ProduktLoopiaKategori")) 70 { 71 var spec = prodSpecs.GetByKey(specKey, ","); 72 <tr> 73 <td class="table-specs-label fw-bold"> 74 @(spec.Caption) 75 </td> 76 <td class="table-specs-value"> 77 @spec.Value @spec.Unit 78 </td> 79 </tr> 80 } 81 </tbody> 82 </table> 83 </div> 84 </div> 85 </div> 86 }
Beklager. Der er ikke noget at se her