LEARNING CENTRE
Stay up to date on the latest in hand protection!
Explore our curated collection of articles to learn more about hand protection, from choosing the correct gloves for specific tasks to the latest in glove technology advancements.
Our resources are ideal for experienced safety professionals and frontline workers who want to stay updated on trends in hand protection. Gain valuable insights today.
Error executing template "Designs/Swift/ItemPublisher/List/List.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_dc132462032f4016b91cc3bfea9ac90d.Execute() in D:\dynamicweb.net\Solutions\Degree\granberg.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\ItemPublisher\List\List.cshtml:line 141 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.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using System.IO 3 4 @foreach (LoopItem item in GetLoop("ItemPublisher:Items.List")) 5 { 6 string title = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Title")) && !item.GetBoolean("ItemPublisher:Item.HideTitle") ? item.GetString("ItemPublisher:Item.Title") : string.Empty; 7 string coverTitle = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverTitle")) ? item.GetString("ItemPublisher:Item.CoverTitle") : string.Empty; 8 string coverImagePath = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverImage")) ? item.GetString("ItemPublisher:Item.CoverImage") : string.Empty; 9 string coverImage = !string.IsNullOrEmpty(coverImagePath) ? $"/Admin/Public/GetImage.ashx?image={coverImagePath}&Width=960&Quality=75&format=webp" : string.Empty; 10 bool hasFocalPoint = item.GetBoolean("ItemPublisher:Item.CoverImage.ImageHasFocalPoint"); 11 int focalX = hasFocalPoint ? item.GetInteger("ItemPublisher:Item.CoverImage.FocalX") : 0; 12 int focalY = hasFocalPoint ? item.GetInteger("ItemPublisher:Item.CoverImage.FocalY") : 0; 13 int xPos = 100 - ((100 - focalX) / 2); 14 int yPos = ((100 - focalY) / 2); 15 string cssPosition = $"{xPos}% {yPos}%"; 16 string summary = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Summary")) ? item.GetString("ItemPublisher:Item.Summary") : string.Empty; 17 string publishedDate = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.PublishedDate")) && !item.GetBoolean("ItemPublisher:Item.HidePublishedDate") ? item.GetDate("ItemPublisher:Item.PublishedDate").ToShortDateString() : string.Empty; 18 string link = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.Url")) ? item.GetString("ItemPublisher:Item.Url") : string.Empty; 19 bool showButton = Pageview.CurrentParagraph.Item["ShowButton"] != null ? (Boolean)Pageview.CurrentParagraph.Item["ShowButton"] : false; 20 string buttonLabel = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.ButtonLabel")) ? item.GetString("ItemPublisher:Item.ButtonLabel") : string.Empty; 21 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 22 string articleItemLayout = Pageview.CurrentParagraph.Item["ArticleItemLayout"] != null ? Pageview.CurrentParagraph.Item["ArticleItemLayout"].ToString() : string.Empty; 23 string articleItemLayoutClass = string.Empty; 24 string titleFontSize = Pageview.CurrentParagraph.Item["TitleFontSize"] != null ? Pageview.CurrentParagraph.Item["TitleFontSize"].ToString() : string.Empty; 25 string gridSettings = Pageview.CurrentParagraph.Item["GridSettings"] != null ? Pageview.CurrentParagraph.Item["GridSettings"].ToString() : "4"; 26 string carouselSettings = Pageview.CurrentParagraph.Item["CarouselSettings"] != null ? Pageview.CurrentParagraph.Item["CarouselSettings"].ToString() : "4"; 27 bool renderContentWrapper = true; 28 bool renderArticleInfoWrapper = true; 29 30 if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(summary) && string.IsNullOrEmpty(publishedDate) && item.GetInteger("ItemPublisher:Item.Author") == 0 && !showButton) 31 { 32 renderContentWrapper = false; 33 } 34 35 if (string.IsNullOrEmpty(publishedDate) && item.GetInteger("ItemPublisher:Item.Author") == 0) 36 { 37 renderArticleInfoWrapper = false; 38 } 39 40 switch (articleItemLayout) 41 { 42 case "image-top": 43 articleItemLayoutClass = "d-flex flex-column"; 44 break; 45 case "image-left": 46 case "image-right": 47 articleItemLayoutClass = !string.IsNullOrEmpty(coverImage) && renderContentWrapper ? "d-flex flex-column flex-lg-row" : "d-flex flex-column"; 48 break; 49 } 50 51 string orderReverseClass = articleItemLayout == "image-right" ? "order-first order-lg-last" : string.Empty; 52 53 string ratio = Pageview.CurrentParagraph.Item["ImageAspectRatio"] != null ? Pageview.CurrentParagraph.Item["ImageAspectRatio"].ToString() : string.Empty; 54 ratio = ratio != "0" ? ratio : string.Empty; 55 string ratioCssClass = ratio != string.Empty ? " ratio" : string.Empty; 56 string ratioVariable = ratio != string.Empty ? "style=\"--bs-aspect-ratio: " + ratio + "\"" : string.Empty; 57 string imageObjectFit = ratio != string.Empty ? "object-fit: cover;" : "object-fit: contain;"; 58 59 string articleItemTheme = Pageview.CurrentParagraph.Item["ArticleItemTheme"] != null ? Pageview.CurrentParagraph.Item["ArticleItemTheme"].ToString() : string.Empty; 60 string coverTheme = !string.IsNullOrEmpty(item.GetString("ItemPublisher:Item.CoverTheme")) ? item.GetString("ItemPublisher:Item.CoverTheme") : string.Empty; 61 string themePadding = string.Empty; 62 string themeClass = string.Empty; 63 string gapClass = " gap-3 gap-md-4"; 64 string articleItemShape = Pageview.CurrentParagraph.Item["ArticleItemShape"] != null ? Pageview.CurrentParagraph.Item["ArticleItemShape"].ToString() : "boxed"; 65 string shapeClass = string.Empty; 66 string coverImageWrapperClass = string.Empty; 67 68 if (!string.IsNullOrEmpty(coverTheme)) 69 { 70 articleItemTheme = coverTheme; 71 } 72 73 if (articleItemTheme != string.Empty) 74 { 75 themePadding = " p-3 p-md-4"; 76 themeClass = " theme " + articleItemTheme + " shadow-hover"; 77 gapClass = " gap-0"; 78 } 79 80 if (articleItemShape == "rounded") 81 { 82 shapeClass = " rounded-4 rounded-lg-5"; 83 } 84 85 <article class="@articleItemLayoutClass@(gapClass)@(themeClass)@(shapeClass) overflow-hidden lift" itemscope itemtype="https://schema.org/CreativeWork"> 86 87 @if (Path.GetExtension(coverImagePath).ToLower() == ".svg") 88 { 89 if (!renderContentWrapper) 90 { 91 coverImageWrapperClass = "d-flex justify-content-center align-items-center h-100 w-100 "; 92 } 93 else 94 { 95 coverImageWrapperClass = "pt-3 pt-md-4 w-100 "; 96 } 97 98 <a class="@(coverImageWrapperClass)@(orderReverseClass)" title="@title" href="@link" tabindex="-1"> 99 <div class="d-flex justify-content-center align-items-center overflow-hidden@(ratioCssClass)" @ratioVariable> 100 @ReadFile(coverImagePath) 101 </div> 102 </a> 103 } 104 else 105 { 106 if (articleItemLayout == "image-top") 107 { 108 <a class="@(orderReverseClass)" title="@title" href="@link" tabindex="-1"> 109 <figure class="overflow-hidden m-0 mx-auto@(ratioCssClass)" @ratioVariable> 110 @RenderImage(coverImagePath, title, cssPosition, articleItemLayout, imageObjectFit, gridSettings, carouselSettings) 111 </figure> 112 </a> 113 } 114 else 115 { 116 if (renderContentWrapper) 117 { 118 coverImageWrapperClass = "w-100 "; 119 } 120 121 <a class="@(coverImageWrapperClass)@(orderReverseClass)" title="@title" href="@link" tabindex="-1"> 122 123 <figure class="h-lg-100 overflow-hidden m-0 mx-auto ratio ratio-16x9"> 124 @RenderImage(coverImagePath, title, cssPosition, articleItemLayout, imageObjectFit, gridSettings, carouselSettings) 125 </figure> 126 </a> 127 } 128 } 129 130 @if (renderContentWrapper) 131 { 132 <div class="d-flex flex-column flex-grow-1 gap-3 w-100@(themePadding)"> 133 134 @if (renderArticleInfoWrapper) 135 { 136 <div class="d-flex align-items-center justify-content-between gap-3"> 137 @if (item.GetInteger("ItemPublisher:Item.Author") != 0) 138 { 139 int authorID = item.GetInteger("ItemPublisher:Item.Author"); 140 var author = Dynamicweb.Security.UserManagement.User.GetUserByID(authorID); 141 string authorImage = !string.IsNullOrEmpty(author.Image) ? author.Image : string.Empty; 142 string authorImagePath = !string.IsNullOrEmpty(author.Image) ? $"/Admin/Public/GetImage.ashx?image={author.Image}&width=48&height=48&Crop=0&Quality=100&format=webp" : string.Empty; 143 string authorName = !string.IsNullOrEmpty(author.Name) ? authorName = author.Name : string.Empty; 144 string authorJobTitle = !string.IsNullOrEmpty(author.JobTitle) ? authorJobTitle = author.JobTitle : string.Empty; 145 146 <div class="d-flex align-items-center gap-2 fs-8 opacity-75"> 147 148 @if (!string.IsNullOrEmpty(authorImage)) 149 { 150 <img class="img-fluid rounded-circle" src="@authorImagePath" loading="lazy" alt="@authorName" width="32" height="32"> 151 } 152 else 153 { 154 <div class="d-flex align-items-center justify-content-center rounded-circle" style="background-color: rgba(var(--swift-foreground-color-rgb),.25)"> 155 <div class="icon-2 p-2"> 156 @ReadFile(iconPath + "user.svg") 157 </div> 158 </div> 159 } 160 161 <div class="d-flex flex-column lh-1 gap-1"> 162 @if (!string.IsNullOrEmpty(authorName)) 163 { 164 <span itemprop="author">@authorName</span> 165 } 166 @if (!string.IsNullOrEmpty(authorJobTitle)) 167 { 168 <span class="opacity-75">@authorJobTitle</span> 169 } 170 </div> 171 </div> 172 } 173 @if (!string.IsNullOrEmpty(publishedDate)) 174 { 175 176 string articleDateTime = item.GetDate("ItemPublisher:Item.PublishedDate").Year + "-" + item.GetDate("ItemPublisher:Item.PublishedDate").Month + "-" + item.GetDate("ItemPublisher:Item.PublishedDate").Day; 177 178 <div class="d-flex align-items-center gap-1 fs-8 opacity-75"> 179 <div class="icon-1"> 180 @ReadFile(iconPath + "calendar.svg") 181 </div> 182 <time datetime="@articleDateTime" itemprop="datePublished">@publishedDate</time> 183 </div> 184 } 185 186 </div> 187 } 188 189 @if (!string.IsNullOrEmpty(title)) 190 { 191 <a class="text-decoration-none text-decoration-underline-hover" href="@link"> 192 <h3 class="@titleFontSize mb-0" itemprop="headline">@title</h3> 193 </a> 194 } 195 @if (!string.IsNullOrEmpty(summary)) 196 { 197 <p class="m-0 opacity-75">@summary</p> 198 } 199 200 201 @if (showButton) 202 { 203 if (!string.IsNullOrEmpty(buttonLabel)) 204 { 205 <a href="@link" class="text-start btn btn-link p-0 mt-auto"> 206 @buttonLabel 207 <span class="icon-2"> 208 @ReadFile(iconPath + "arrow-right.svg") 209 </span> 210 </a> 211 } 212 else 213 { 214 <a href="@link" class="btn btn-link p-0 lh-1 text-start mt-auto"> 215 <span class="icon-3"> 216 @ReadFile(iconPath + "arrow-right.svg") 217 </span> 218 </a> 219 } 220 } 221 </div> 222 } 223 </article> 224 } 225 226 @helper RenderImage(string coverImagePath, string title, string cssPosition, string articleItemLayout, string imageObjectFit, string gridSettings, string carouselSettings) 227 { 228 coverImagePath = Dynamicweb.Context.Current.Server.UrlEncode(coverImagePath); 229 230 if (articleItemLayout != "image-top") 231 { 232 imageObjectFit = "object-fit: cover"; 233 } 234 235 string imgSizeSelector = "50vw"; 236 237 if (gridSettings == "1" || carouselSettings == "1") 238 { 239 imgSizeSelector = "100vw"; 240 } 241 else if (gridSettings == "2" || carouselSettings == "2") 242 { 243 imgSizeSelector = "50vw"; 244 } 245 else if (gridSettings == "3" || carouselSettings == "3") 246 { 247 imgSizeSelector = "33vw"; 248 } 249 else if (gridSettings == "4" || carouselSettings == "4") 250 { 251 imgSizeSelector = "25vw"; 252 } 253 else if (gridSettings == "5" || carouselSettings == "5") 254 { 255 imgSizeSelector = "17vw"; 256 } 257 258 string coverImagePathM = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=640&quality=85&format=webp"; 259 string coverImagePathL = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=960&quality=85&format=webp"; 260 string coverImagePathXL = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=1280&quality=85&format=webp"; 261 string coverImagePathXXL = $"/Admin/Public/GetImage.ashx?image={coverImagePath}&width=1920&quality=85&format=webp"; 262 string imagePathFallBack = coverImagePathM; 263 264 <img srcset=" 265 @coverImagePathM 640w, 266 @coverImagePathL 960w, 267 @coverImagePathXL 1280w, 268 @coverImagePathXXL 1920w" 269 src="@imagePathFallBack" 270 sizes="(min-width: 992px) @imgSizeSelector, 100vw" 271 loading="lazy" 272 decoding="async" 273 class="img-fluid image-zoom-lg-1-hover" 274 style="@imageObjectFit; object-position: @cssPosition;" 275 alt="@title"> 276 } 277