Swift

Download Product Assets

On this list you can find relevant products, where you can use the filters to narrow down your search. Add products to your download cart. The selected product information and product assets (images, drawings etc.) will be send to the selected email address.

Sort by

Brand

Error executing template "Designs/Swift-v2/Paragraph/./Swift-v2_ProductGroupGrid.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_9ddb9e24076b4bd08f78c8ce7c676c71.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 @using Dynamicweb.Frontend 5 6 @functions 7 { 8 private IList<ProductGroupViewModel> GetGroups(string type) 9 { 10 IList<ProductGroupViewModel> groupList = new List<ProductGroupViewModel> { }; 11 12 if (type == "subgroups") 13 { 14 IList<ProductGroupViewModel> groups = Model.Item.GetValue<IList<ProductGroupViewModel>>("Subgroups"); 15 if (groups != null) 16 { 17 foreach (var group in groups) 18 { 19 var subGroups = Services.ProductGroups.GetSubgroups(Services.ProductGroups.GetGroup(group.Id)); 20 21 foreach (var subGroup in subGroups) 22 { 23 var subGroupViewModel = ViewModelFactory.CreateView(new ProductGroupViewModelSettings(), subGroup); 24 groupList.Add(subGroupViewModel); 25 } 26 } 27 } 28 } 29 30 if (type == "selected-groups") 31 { 32 IList<ProductGroupViewModel> groups = Model.Item.GetValue<IList<ProductGroupViewModel>>("SelectedGroups"); 33 if (groups != null) 34 { 35 foreach (var group in groups) 36 { 37 groupList.Add(group); 38 } 39 } 40 } 41 42 if (type == "subgroups-current") 43 { 44 var currentGroupId = Dynamicweb.Context.Current.Request.QueryString.Get("GroupID"); 45 var currentGroup = currentGroupId != null ? Services.ProductGroups.GetGroup(currentGroupId) : null; 46 var groups = currentGroup != null ? Services.ProductGroups.GetSubgroups(currentGroup) : null; 47 if (groups != null) 48 { 49 foreach (var group in groups) 50 { 51 var groupViewModel = ViewModelFactory.CreateView(new ProductGroupViewModelSettings(), group); 52 groupList.Add(groupViewModel); 53 } 54 } 55 } 56 57 return groupList; 58 } 59 60 private LinkViewModel GetLink(ProductGroupViewModel group) 61 { 62 var link = new LinkViewModel() 63 { 64 Url = $"/Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={group.Id.Trim()}", 65 IsExternal = false 66 }; 67 68 return link; 69 } 70 71 private string GetGroupImageMarkup(ProductGroupViewModel group, string imageShape) 72 { 73 string groupImage = Services.ProductGroups.GetGroup(group.Id)?.LargeImage; 74 if (groupImage.StartsWith("/") && !groupImage.StartsWith("/Files", StringComparison.OrdinalIgnoreCase)) 75 { 76 groupImage = $"/Files{groupImage}"; 77 } 78 79 string groupImageEncoded = Dynamicweb.Context.Current.Server.UrlEncode(groupImage); 80 string groupImagePath = $"/Admin/Public/GetImage.ashx?width=640&crop=0&image={groupImageEncoded}&format=webp"; 81 string groupImageMarkup = $"<img class=\"{imageShape}\" src=\"{groupImagePath}\" alt=\"{group.Name}\" style=\"object-fit:contain\">"; 82 83 return !string.IsNullOrEmpty(groupImage) ? groupImageMarkup : string.Empty; 84 } 85 86 private string GetImageShape() 87 { 88 string imageShape = Model.Item.GetRawValueString("ImageShape", "boxed"); 89 switch (imageShape) 90 { 91 case "boxed": 92 imageShape = "rounded-0"; 93 break; 94 case "rounded": 95 imageShape = "rounded-3"; 96 break; 97 case "circle": 98 imageShape = "rounded-pill"; 99 break; 100 } 101 return imageShape; 102 } 103 104 private string GetButtonAlignment() 105 { 106 string buttonAlignment = Model.Item.GetRawValueString("ButtonAlignment", "align-center-center"); 107 108 switch (buttonAlignment) 109 { 110 case "align-center-center": 111 return "text-center justify-content-center align-items-center"; 112 case "align-bottom-start": 113 return "text-start justify-content-start align-items-end"; 114 case "align-bottom-center": 115 return "text-center justify-content-center align-items-end"; 116 case "align-bottom-center-text-center": 117 return "text-center justify-content-center align-items-end"; 118 case "align-bottom-end": 119 return "text-end justify-content-end align-items-end"; 120 default: 121 return "align-center-center"; 122 } 123 } 124 } 125 126 @{ 127 string groupType = Model.Item.GetRawValueString("GroupType", "subgroups"); 128 var groups = GetGroups(groupType); 129 130 bool hideHeaders = (Model.Item?.GetBoolean("HideHeaders") ?? false); 131 string title = Model.Item?.GetString("Title", string.Empty); 132 string subtitle = Model.Item?.GetString("Subtitle", string.Empty); 133 bool groupsExist = groups is object && groups.Count != 0; 134 135 // Grid layout 136 string gridSize = Model.Item.GetRawValueString("GridSize", "3"); 137 string gridSizeMobile = Model.Item.GetRawValueString("GridSizeMobile", "1"); 138 gridSize = $"grid-{gridSizeMobile} grid-sm-3 grid-lg-{gridSize}"; 139 140 string itemsGap = $"gap-{Model.Item.GetRawValueString("GridItemsGap", "3")}"; 141 string layout = Model.Item.GetRawValueString("Layout", "overlay"); 142 143 // Styling 144 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", string.Empty); 145 ratio = ratio != "0" ? ratio : string.Empty; 146 string ratioCssClass = ratio != string.Empty ? "ratio" : string.Empty; 147 string ratioVariable = ratio != string.Empty ? "--bs-aspect-ratio: " + ratio : string.Empty; 148 149 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "h3"); 150 string subtitleFontSize = Model.Item.GetRawValueString("SubtitleFontSize", "fs-5"); 151 string maxWidth = Model.Item.GetRawValueString("TextReadability", string.Empty); 152 maxWidth = maxWidth == "max-width-on" ? "mw-75ch" : string.Empty; 153 154 bool hideButtons = Model.Item.GetBoolean("CustomHideButtons"); 155 string buttonAlignment = GetButtonAlignment(); 156 157 string buttonStyle = Model.Item.GetRawValueString("ButtonStyle", "primary"); 158 159 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 160 buttonSize = buttonSize == "small" ? "btn btn-sm" : buttonSize; 161 buttonSize = buttonSize == "regular" ? "btn" : buttonSize; 162 buttonSize = buttonSize == "large" ? "btn btn-lg" : buttonSize; 163 164 string stretchedLink = "stretched-link"; 165 166 string imageShape = GetImageShape(); 167 @*Custom added pill layout*@ 168 string display = "grid"; 169 string innerLayout = "d-flex flex-column h-100"; 170 string outerWrapperClass = string.Empty; 171 string headerAlign = string.Empty; 172 173 174 if (layout.Equals("custom-pill", StringComparison.InvariantCultureIgnoreCase)) 175 { 176 gridSize = string.Empty; 177 display = "d-flex flex-row flex-wrap"; 178 innerLayout = "custom-pill"; 179 imageShape = "h-100"; 180 } 181 @*Custom added centered pill layout*@ 182 else if (layout.Equals("custom-pill-centered", StringComparison.InvariantCultureIgnoreCase)) 183 { 184 gridSize = string.Empty; 185 display = "d-flex flex-row flex-wrap justify-content-center"; 186 innerLayout = "custom-pill"; 187 imageShape = "h-100"; 188 outerWrapperClass = "custom-pill-centered-wrapper"; 189 headerAlign = "text-center"; 190 } 191 192 string missingImageMarkup = $"<div class=\"bg-opacity-10 {imageShape}\" style=\"background-color:rgba(var(--swift-foreground-color-rgb),var(--bs-bg-opacity));\"></div>"; 193 } 194 195 @if (groupsExist) 196 { 197 <div class="grid gap-0 item_@(Model.Item.SystemName.ToLower()) @outerWrapperClass"> 198 199 @if (!hideHeaders) 200 { 201 <div class="g-col-12 pb-2 pb-lg-4 @headerAlign"> 202 <div class="mb-0-last-child"> 203 @if (!string.IsNullOrEmpty(title)) 204 { 205 <h2 class="mt-0 @titleFontSize @maxWidth">@title</h2> 206 } 207 208 @if (!string.IsNullOrEmpty(subtitle)) 209 { 210 <p class="@subtitleFontSize @maxWidth">@subtitle</p> 211 } 212 </div> 213 </div> 214 } 215 216 <div class="g-col-12 @display @gridSize @itemsGap row-gap-3"> 217 @foreach (var group in groups) 218 { 219 string groupImageMarkup = GetGroupImageMarkup(group, imageShape) ?? missingImageMarkup; 220 bool groupImage = !string.IsNullOrEmpty(groupImageMarkup); 221 bool openLinksInNewTab = Pageview.AreaSettings.GetBoolean("OpenLinksInNewTab") && GetLink(group).IsExternal; 222 string target = openLinksInNewTab ? "target=\"_blank\"" : string.Empty; 223 string rel = openLinksInNewTab ? "rel=\"noopener\"" : string.Empty; 224 225 <div class="@innerLayout"> 226 @{ 227 switch (layout) 228 { 229 case "overlay": 230 <div class="card rounded-0 border-0 @(ratioCssClass)" style="@ratioVariable"> 231 232 @(groupImage ? groupImageMarkup : missingImageMarkup) 233 234 @if (!hideButtons) 235 { 236 <div class="d-grid p-3 @buttonAlignment"> 237 @if (GetLink(group) is object) 238 { 239 <a href="@GetLink(group)" class="@(buttonSize) btn-@buttonStyle @(stretchedLink)" data-dw-button="@buttonStyle" @target @rel>@group.Name</a> 240 } 241 </div> 242 } 243 else 244 { 245 <a href="@GetLink(group)" class="@(stretchedLink)" @target @rel></a> 246 } 247 </div> 248 break; 249 case "below": 250 <div class="card rounded-0 border-0 gap-3"> 251 252 <div class="@(ratioCssClass)" style="@ratioVariable"> 253 254 @(groupImage ? groupImageMarkup : missingImageMarkup) 255 256 </div> 257 258 <div class="@(groupImage ? "h-100" : string.Empty) d-grid @buttonAlignment"> 259 260 @if (!hideButtons) 261 { 262 @if (GetLink(group) is object) 263 { 264 <a href="@GetLink(group)" class="@(buttonSize) btn-@buttonStyle @(stretchedLink)" data-dw-button="@buttonStyle" @target @rel>@group.Name</a> 265 } 266 } 267 else 268 { 269 <a href="@GetLink(group)" class="@(stretchedLink)" @target @rel></a> 270 } 271 </div> 272 </div> 273 break; 274 case "custom-pill": 275 case "custom-pill-centered": 276 @(groupImage ? groupImageMarkup : missingImageMarkup) 277 @if (GetLink(group) is object) 278 { 279 <a href="@GetLink(group)" class="@(stretchedLink)" @target @rel></a> 280 } 281 break; 282 } 283 } 284 </div> 285 } 286 </div> 287 </div> 288 } 289 else if (Pageview.IsVisualEditorMode) 290 { 291 <div class="alert alert-dark" role="alert"> 292 <span>@Translate("Group grid"): @Translate("Edit this column to configure")</span> 293 </div> 294 } 295