An error occurred while attaching module (Dynamicweb.Frontend.Content)
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.ProductRepository.GetProductById(String productId, String productVariantId, String productLanguageId)
at Dynamicweb.Ecommerce.Products.ProductService.FetchMissingProductsInternal(IProductRepository repo, IEnumerable`1 keys)
at Dynamicweb.Caching.ServiceCache`2.GetCache(IEnumerable`1 keys)
at Dynamicweb.Caching.ServiceCache`2.GetCache(TKey key)
at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, User user, Boolean showUntranslated)
at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, Boolean useAssortments)
at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.IsProductInCorrectGroup(String groupId, String productId, String variantId, String languageId)
at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.RenderProduct(String productId, String variantId, String groupId, ProductCatalogSettings settings)
at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.GetContent()
at Dynamicweb.Frontend.Content.GetModuleOutput(Paragraph paragraph, PageView pageview)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:53,State:0,Class:20
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.ProductRepository.GetProductById(String productId, String productVariantId, String productLanguageId) at Dynamicweb.Ecommerce.Products.ProductService.FetchMissingProductsInternal(IProductRepository repo, IEnumerable`1 keys) at Dynamicweb.Caching.ServiceCache`2.GetCache(IEnumerable`1 keys) at Dynamicweb.Caching.ServiceCache`2.GetCache(TKey key) at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, User user, Boolean showUntranslated) at Dynamicweb.Ecommerce.Products.ProductService.GetProductById(String productId, String productVariantId, String productLanguageId, Boolean useAssortments) at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.IsProductInCorrectGroup(String groupId, String productId, String variantId, String languageId) at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.RenderProduct(String productId, String variantId, String groupId, ProductCatalogSettings settings) at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.GetContent() at Dynamicweb.Frontend.Content.GetModuleOutput(Paragraph paragraph, PageView pageview) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:53,State:0,Class:20
Vi löser specialbeställningar, fler varianter vid förfrågan!
Error executing template "Designs/Swift/Paragraph/Swift_RelatedProducts.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_1732a3cb342b4deb8b7d7a46d54dbd6a.Execute() in D:\dynamicweb.net\Solutions\Capo\pretec.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_RelatedProducts.cshtml:line 186 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 bool productViewModelFound = false; 7 ProductViewModel product = new ProductViewModel(); 8 9 ProductViewModelSettings productSetting = new ProductViewModelSettings 10 { 11 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 12 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 13 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 14 ShopId = Pageview.Area.EcomShopId 15 }; 16 17 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 18 { 19 productViewModelFound = true; 20 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 21 } 22 if (Pageview.IsVisualEditorMode && !productViewModelFound) 23 { 24 if (Pageview.Item["DummyProduct"] != null) 25 { 26 productViewModelFound = true; 27 string dummyProductId = ""; 28 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 29 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 30 if (productList.Products != null) 31 { 32 foreach (var p in productList.Products) { dummyProductId = p.Id; } 33 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 34 product = dummyProduct; 35 } 36 else 37 { 38 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 39 } 40 } 41 else if (Pageview.Item["DummyProduct"] == null) 42 { 43 productViewModelFound = true; 44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 45 } 46 } 47 48 string title = Model?.Item?.GetString("Title") != null ? Model.Item.GetString("Title") : Translate("Products"); 49 50 string campaignValues = Model.Item.GetRawValueString("CampaignBadges", string.Empty); 51 52 //Styling 53 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 54 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 55 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", ""); 56 buttonStyle = buttonStyle == "primary" ? " btn-primary" : buttonStyle; 57 buttonStyle = buttonStyle == "secondary" ? " btn-secondary" : buttonStyle; 58 buttonStyle = buttonStyle == "link" ? " btn-link" : buttonStyle; 59 string maxWidth = Model.Item.GetRawValueString("TextReadability", ""); 60 maxWidth = maxWidth == "max-width-on" ? " mw-75ch" : maxWidth; 61 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth; 62 63 string generalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("GeneralTheme")) ? " theme " + Model.Item.GetRawValueString("GeneralTheme").Replace(" ", "").Trim().ToLower() : ""; 64 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 65 string imageTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 66 67 //Link generation 68 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 69 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : ""; 70 pageId = pageId == "" ? servicePageByNavigationTag : pageId; 71 72 string url = "/Default.aspx?ID=" + pageId; 73 if (!url.Contains("LayoutTemplate")) 74 { 75 url += url.Contains("?") ? "&LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml" : "?LayoutTemplate=Designs/Swift/Swift_PageClean.cshtml"; 76 } 77 if (Pageview.IsVisualEditorMode) 78 { 79 url += "&VisualEdit=True"; 80 } 81 82 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 83 if (isLazyLoadingForProductInfoEnabled) 84 { 85 url += "&getproductinfo=true"; 86 } 87 88 //Source type 89 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 90 IList<string> relateFromGroupIds = new List<string> { }; 91 IList<string> relateFromProductIds = new List<string> { }; 92 93 //--- VARIANTS --- 94 ProductListViewModel productsToRelateToVariants = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateToVariants"); 95 if (productsToRelateToVariants != null && sourceType == "variants") 96 { 97 foreach (var productSelection in productsToRelateToVariants.Products) 98 { 99 relateFromProductIds.Add(productSelection.Id); 100 } 101 } 102 103 //--- MOST SOLD --- 104 IList<ProductGroupViewModel> groupsToRelateToMostSold = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToMostSold"); 105 if (groupsToRelateToMostSold != null && sourceType == "most-sold") 106 { 107 foreach (var fromGroup in groupsToRelateToMostSold) 108 { 109 relateFromGroupIds.Add(fromGroup.Id); 110 } 111 } 112 113 //--- TRENDING --- 114 IList<ProductGroupViewModel> groupsToRelateToTrending = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToTrending"); 115 if (groupsToRelateToTrending != null && sourceType == "trending") 116 { 117 foreach (var fromGroup in groupsToRelateToTrending) 118 { 119 relateFromGroupIds.Add(fromGroup.Id); 120 } 121 } 122 123 //--- LATEST --- 124 IList<ProductGroupViewModel> groupsToRelateToLatest = Model.Item.GetValue<IList<ProductGroupViewModel>>("GroupsToRelateToLatest"); 125 if (groupsToRelateToLatest != null && sourceType == "latest") 126 { 127 foreach (var fromGroup in groupsToRelateToLatest) 128 { 129 relateFromGroupIds.Add(fromGroup.Id); 130 } 131 } 132 133 //--- FREQUENTLY BOUGHT --- 134 ProductListViewModel productsToRelateTo = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo"); 135 if (productsToRelateTo != null && sourceType == "frequently") 136 { 137 foreach (var fromProduct in productsToRelateTo.Products) 138 { 139 relateFromProductIds.Add(fromProduct.Id); 140 } 141 } 142 143 //--- SELECTED PRODUCTS --- 144 ProductListViewModel products = Model.Item.GetValue<ProductListViewModel>("Products"); 145 if (products != null && sourceType == "selected") 146 { 147 foreach (var productSelection in products.Products) 148 { 149 relateFromProductIds.Add(productSelection.Id); 150 } 151 } 152 153 //--- RELATED PRODUCTS --- 154 if (sourceType == "related-products") 155 { 156 ProductListViewModel selectedRelationProduct = Model.Item.GetValue<ProductListViewModel>("ProductsToRelateTo2"); 157 if (selectedRelationProduct?.Products != null) 158 { 159 if (selectedRelationProduct.Products.Count > 0) 160 { 161 int productCount = 0; 162 foreach (var selectedProduct in selectedRelationProduct.Products) 163 { 164 if (productCount == 0) 165 { 166 product = selectedProduct; 167 productCount++; 168 } 169 } 170 } 171 } 172 173 if (product?.RelatedGroups != null) 174 { 175 foreach (var group in product.RelatedGroups) 176 { 177 foreach (var relatedProduct in group.Products) 178 { 179 relateFromProductIds.Add(relatedProduct.ProductId); 180 } 181 } 182 } 183 } 184 185 //Create group id collection and products id collection strings 186 string groupIds = productViewModelFound ? product.PrimaryOrDefaultGroup.Id : string.Join(",", relateFromGroupIds); 187 string productIds = productViewModelFound && relateFromProductIds.Count == 0 ? product.Id : string.Join(",", relateFromProductIds); 188 189 //Set the parameters to the url 190 string linkParameters = ""; 191 linkParameters += sourceType != "related-products" ? "&GroupId=" + groupIds : ""; 192 linkParameters += !string.IsNullOrEmpty(productIds) ? "&MainProductId=" + productIds : ""; 193 var productListPageId = GetPageIdByNavigationTag("Shop"); 194 string link = "/Default.aspx?ID=" + productListPageId + linkParameters; 195 196 // Slider settings (documentation: swiffyslider.com/configuration) 197 string navigationStyle = $"{Model.Item.GetRawValueString("NavigationStyle", "slider-nav-round")}"; 198 string navigationPlacement = $"{Model.Item.GetRawValueString("NavigationPlacement", "slider-nav-on-slides")}"; 199 string indicatorStyle = $"{Model.Item.GetRawValueString("IndicatorStyle", "slider-indicators-hidden")}"; 200 string revealSlides = Model.Item.GetRawValueString("RevealSlides", "no-reveal") == "reveal" ? "slider-item-reveal" : string.Empty; 201 string navigationAlwaysVisible = (Model.Item.GetBoolean("NavigationAlwaysVisible")) ? "slider-nav-visible" : string.Empty; 202 string navigationVisibleOnTouch = (Model.Item.GetBoolean("NavigationVisibleOnTouch")) ? "slider-nav-touch" : string.Empty; 203 string navigationShowScrollbar = (Model.Item.GetBoolean("NavigationShowScrollbar")) ? "slider-nav-scrollbar" : string.Empty; 204 string navigationSmall = (Model.Item.GetBoolean("NavigationSmall")) ? "slider-nav-sm" : string.Empty; 205 string navigationInvertColors = (Model.Item.GetBoolean("NavigationInvertColors")) ? "slider-nav-dark" : string.Empty; 206 string navigationSlideEntirePage = (Model.Item.GetBoolean("NavigationSlideEntirePage")) ? "slider-nav-page" : string.Empty; 207 string navigationNoLoop = (Model.Item.GetBoolean("NavigationNoLoop")) ? "slider-nav-noloop" : string.Empty; 208 string indicatorsOutsideSlider = (Model.Item.GetBoolean("IndicatorsOutsideSlider") && indicatorStyle != string.Empty) ? "slider-indicators-outside" : string.Empty; 209 string indicatorsHighlightActive = (Model.Item.GetBoolean("IndicatorsHighlightActive")) ? "slider-indicators-highlight" : string.Empty; 210 string indicatorsInvertColors = (Model.Item.GetBoolean("IndicatorsInvertedColors")) ? "slider-indicators-dark" : string.Empty; 211 string indicatorsVisibleOnSmallDevices = (Model.Item.GetBoolean("IndicatorsVisibleOnSmallDevices")) ? "slider-indicators-sm" : string.Empty; 212 213 bool productsFound = true; 214 if (string.IsNullOrEmpty(groupIds) && string.IsNullOrEmpty(productIds)) 215 { 216 if (Pageview.IsVisualEditorMode) 217 { 218 productIds = product.Id; 219 sourceType = "selected"; 220 } 221 else 222 { 223 productsFound = false; 224 } 225 } 226 } 227 228 @*Container element for the request*@ 229 @if (productsFound) 230 { 231 <form method="post" action="@url" id="RelatedProductsForm_@Model.ID" data-response-target-element="RelatedProducts_@Model.ID" data-preloader="inline" data-update-url="false" class="item_@Model.Item.SystemName.ToLower()"> 232 <input type="hidden" name="ModelID" value="@Model.ID"> 233 <input type="hidden" name="SourceType" value="@sourceType"> 234 235 @*--- SLIDER SETTINGS ---*@ 236 <input type="hidden" name="NavigationStyle" value="@navigationStyle"> 237 <input type="hidden" name="NavigationPlacement" value="@navigationPlacement"> 238 <input type="hidden" name="IndicatorStyle" value="@indicatorStyle"> 239 <input type="hidden" name="RevealSlides" value="@revealSlides"> 240 <input type="hidden" name="NavigationAlwaysVisible" value="@(navigationAlwaysVisible)"> 241 <input type="hidden" name="NavigationVisibleOnTouch" value="@(navigationVisibleOnTouch)"> 242 <input type="hidden" name="NavigationShowScrollbar" value="@(navigationShowScrollbar)"> 243 <input type="hidden" name="NavigationSmall" value="@(navigationSmall)"> 244 <input type="hidden" name="NavigationInvertColors" value="@(navigationInvertColors)"> 245 <input type="hidden" name="NavigationNoLoop" value="@(navigationNoLoop)"> 246 <input type="hidden" name="NavigationSlideEntirePage" value="@(navigationSlideEntirePage)"> 247 <input type="hidden" name="IndicatorsOutsideSlider" value="@(indicatorsOutsideSlider)"> 248 <input type="hidden" name="IndicatorsHighlightActive" value="@(indicatorsHighlightActive)"> 249 <input type="hidden" name="IndicatorsInvertColors" value="@(indicatorsInvertColors)"> 250 <input type="hidden" name="IndicatorsVisibleOnSmallDevices" value="@(indicatorsVisibleOnSmallDevices)"> 251 252 @*--- VARIANTS ---*@ 253 @if (sourceType == "variants") 254 { 255 <input type="hidden" name="isVariant" value="true"> 256 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds"> 257 } 258 259 @*--- MOST SOLD ---*@ 260 @if (sourceType == "most-sold") 261 { 262 <input type="hidden" name="SortBy" value="OrderCount"> 263 if (groupIds != "") 264 { 265 <input type="hidden" name="GroupId" value="@groupIds"> 266 } 267 } 268 269 @*--- TRENDING ---*@ 270 @if (sourceType == "trending") 271 { 272 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 273 if (groupIds != "") 274 { 275 <input type="hidden" name="GroupId" value="@groupIds"> 276 } 277 } 278 279 @*--- FREQUENTLY BOUGHT ---*@ 280 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 281 { 282 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 283 } 284 285 @*--- LATEST ---*@ 286 @if (sourceType == "latest") 287 { 288 <input type="hidden" name="SortBy" value="Created"> 289 <input type="hidden" name="GroupId" value="@groupIds"> 290 } 291 292 @*--- SELECTED PRODUCTS ---*@ 293 @if (sourceType == "selected") 294 { 295 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds"> 296 } 297 298 @*--- RELATED PRODUCTS ---*@ 299 @if (sourceType == "related-products") 300 { 301 <input type="hidden" name="MainProductID" id="MainProductID_@Model.ID" value="@productIds"> 302 } 303 304 @* General parameters *@ 305 <input type="hidden" name="Link" value="@link" /> 306 <input type="hidden" name="HideTitle" value="@Model.Item.GetString("HideTitle")" /> 307 308 @if (Model.Item.GetInt32("ProductsCount") != 0) 309 { 310 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 311 } 312 <input type="hidden" name="HeadingTitle" id="RelatedProductsTitle_@Model.ID" value="@title"> 313 @if (!string.IsNullOrEmpty(Model.Item.GetString("Subtitle"))) 314 { 315 <input type="hidden" name="Subtitle" value="@Model.Item.GetString("Subtitle")"> 316 } 317 @if (!string.IsNullOrEmpty(Model.Item.GetString("LinkText"))) 318 { 319 <input type="hidden" name="LinkText" value="@Model.Item.GetString("LinkText")"> 320 } 321 @if (!string.IsNullOrEmpty(Model.Item.GetString("ImageAspectRatio"))) 322 { 323 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 324 ratio = ratio != "0" ? ratio : ""; 325 <input type="hidden" name="ImageAspectRatio" value="@ratio"> 326 } 327 @if (!string.IsNullOrEmpty(Model.Item.GetString("Layout"))) 328 { 329 <input type="hidden" name="Layout" value="@Model.Item.GetRawValueString("Layout")"> 330 } 331 @if (titleFontSize != "") 332 { 333 <input type="hidden" name="TitleFontSize" value="@titleFontSize"> 334 } 335 @if (subtitleFontSize != "") 336 { 337 <input type="hidden" name="SubtitleFontSize" value="@subtitleFontSize"> 338 } 339 @if (buttonStyle != "") 340 { 341 <input type="hidden" name="ButtonStyle" value="@buttonStyle"> 342 } 343 @if (generalTheme != "") 344 { 345 <input type="hidden" name="GeneralTheme" value="@generalTheme"> 346 } 347 @if (theme != "") 348 { 349 <input type="hidden" name="Theme" value="@theme"> 350 } 351 @if (imageTheme != "") 352 { 353 <input type="hidden" name="ImageTheme" value="@imageTheme"> 354 } 355 @if (!string.IsNullOrEmpty(Model.Item.GetString("ContentPadding"))) 356 { 357 string contentPadding = Model.Item.GetRawValueString("ContentPadding"); 358 <input type="hidden" name="ContentPadding" value="@contentPadding"> 359 } 360 <input type="hidden" name="TextReadability" value="@maxWidth"> 361 <input type="hidden" name="ParentColumnSize" id="ParentColumnSize_@Model.ID" value="12"> 362 363 <input type="hidden" name="SaleBadgeType" value="@Model.Item.GetRawValue("SaleBadgeType")"> 364 <input type="hidden" name="SaleBadgeCssClassName" value="@Model.Item.GetRawValue("SaleBadgeDesign")"> 365 <input type="hidden" name="NewBadgeCssClassName" value="@Model.Item.GetRawValue("NewBadgeDesign")"> 366 <input type="hidden" name="NewPublicationDays" value="@Model.Item.GetInt32("NewPublicationDays")"> 367 368 @if (campaignValues != "") 369 { 370 <input type="hidden" name="CampaignBadgesValues" value="@campaignValues"> 371 } 372 </form> 373 374 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 375 <script type="module"> 376 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 377 </script> 378 379 if (Pageview.IsVisualEditorMode) 380 { 381 <div class="alert alert-info" role="alert"> 382 <span>@Translate("Product slider: Edit this column to configure")</span> 383 </div> 384 } 385 386 if (sourceType != "related-products") 387 { 388 <div class="w-100 h-100"> 389 <div id="RelatedProducts_@Model.ID" class="h-100 swift_product_slider_container"></div> 390 </div> 391 } 392 else if (product?.RelatedGroups != null) 393 { 394 @* Create multiple slider containers, if type is Product relation *@ 395 <div class="grid w-100 h-100@(generalTheme)" style="grid-row-gap: 4rem"> 396 @foreach (var group in product.RelatedGroups) 397 { 398 <div id="RelatedProducts_@(Model.ID)_@group.Id" class="g-col-12 h-100 swift_product_slider_container"></div> 399 } 400 </div> 401 } 402 403 @* Initialize *@ 404 if (sourceType != "related-products") 405 { 406 <script type="module"> 407 if (document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]")) { 408 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@Model.ID").closest("[data-col-size]").getAttribute("data-col-size"); 409 } 410 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID")).then(function () { 411 setTimeout(function() { 412 const isVisualEditor = @(Converter.ToString(Pageview.IsVisualEditorMode).ToLowerInvariant()); 413 const productSliderContainer = document.querySelector(".swift_product_slider_container"); 414 415 if (productSliderContainer && productSliderContainer.innerHTML !== "") { 416 productSliderContainer.classList.remove("d-none"); 417 } 418 else if (!isVisualEditor) { 419 productSliderContainer.closest("[class*=column]").classList.add("d-none"); 420 } 421 }, 150); 422 }); 423 </script> 424 } 425 else if (product?.RelatedGroups != null) 426 { 427 @* Create multiple sliders, if type is Product relation *@ 428 foreach (var group in product.RelatedGroups) 429 { 430 IList<string> fromProductIds = new List<string> { }; 431 432 foreach (var relatedProduct in group.Products) 433 { 434 fromProductIds.Add(relatedProduct.ProductId); 435 } 436 <script type="module"> 437 document.querySelector("#ParentColumnSize_@Model.ID").value = document.querySelector("#RelatedProducts_@(Model.ID)_@group.Id").closest("[data-col-size]").getAttribute("data-col-size"); 438 document.querySelector("#MainProductID_@Model.ID").value = "@string.Join(",", fromProductIds)"; 439 document.querySelector("#RelatedProductsTitle_@Model.ID").value = "@group.Name"; 440 document.querySelector("#RelatedProductsForm_@Model.ID").setAttribute("data-response-target-element", "RelatedProducts_@(Model.ID)_@group.Id"); 441 442 swift.PageUpdater.Update(document.querySelector("#RelatedProductsForm_@Model.ID")); 443 </script> 444 } 445 } 446 } 447
Sorry. There is nothing to view here