Error executing template "Designs/Rapido/Paragraph/ParagraphContainer.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_b212600e2e3d4b8787b5d3860d6475c2.Execute() in D:\dynamicweb.net\Solutions\lope.LIVE\Files\Templates\Designs\Rapido\Paragraph\ParagraphContainer.cshtml:line 267
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 4 @using Dynamicweb.Frontend 5 6 @helper RenderContent(ItemViewModel item, bool isCarousel = false) 7 { 8 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : "grid__cell"; 9 cardClass = Pageview.Device.ToString() != "Tablet" ? cardClass : "grid__cell"; 10 11 string contentPosition = item.GetList("ContentPositions").SelectedValue; 12 13 switch (contentPosition) { 14 case "title-top": 15 <div class="@cardClass"> 16 @RenderHeading(item) 17 @RenderImage(item, isCarousel) 18 @RenderText(item) 19 @RenderModule(item) 20 </div> 21 @RenderButton(item) 22 break; 23 case "image-left": 24 <div class="grid"> 25 <div class="grid__col-3"> 26 @RenderImage(item, isCarousel) 27 </div> 28 <div class="grid__col-9"> 29 @RenderHeading(item) 30 @RenderText(item) 31 @RenderModule(item) 32 @RenderButton(item) 33 </div> 34 </div> 35 break; 36 case "image-right": 37 <div class="grid"> 38 <div class="grid__col-9"> 39 @RenderHeading(item) 40 @RenderText(item) 41 @RenderModule(item) 42 @RenderButton(item) 43 </div> 44 <div class="grid__col-3"> 45 @RenderImage(item, isCarousel) 46 </div> 47 </div> 48 break; 49 case "all-centered": 50 <div class="u-ta-center @cardClass"> 51 @RenderImage(item, isCarousel) 52 @RenderHeading(item) 53 @RenderText(item) 54 @RenderModule(item) 55 </div> 56 @RenderButton(item) 57 break; 58 case "middle-center": 59 case "middle-left": 60 <div class="u-middle @(contentPosition == "middle-center" ? "u-ta-center" : "")"> 61 <div class="@cardClass"> 62 @RenderImage(item, isCarousel) 63 @RenderHeading(item) 64 @RenderText(item) 65 @RenderModule(item) 66 </div> 67 @RenderButton(item) 68 </div> 69 break; 70 //for "image-top" and "image-centered" 71 default: 72 <div class="@cardClass"> 73 @RenderImage(item, isCarousel) 74 @RenderHeading(item) 75 @RenderText(item) 76 @RenderModule(item) 77 </div> 78 @RenderButton(item) 79 break; 80 } 81 } 82 83 @helper RenderHeading(ItemViewModel item) 84 { 85 if (item.GetBoolean("ShowTitle") != false && !string.IsNullOrEmpty(item.GetString("Title"))) 86 { 87 string headerMargin = item.GetString("Text") != "" && item.GetString("Image") != "" ? "u-margin-bottom" : ""; 88 headerMargin = Model.GetModuleOutput() == "" ? headerMargin : "u-margin-bottom"; 89 string url = item.GetString("Link"); 90 91 if (!String.IsNullOrEmpty(url)) 92 { 93 <a href="@url"> 94 <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> 95 </a> 96 } 97 else 98 { 99 <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> 100 } 101 } 102 } 103 104 @helper RenderButton(ItemViewModel item) 105 { 106 string url = item.GetString("Link"); 107 string linkText = item.GetString("LinkText"); 108 string secondaryUrl = item.GetString("SecondaryLink"); 109 string secondaryLinkText = item.GetString("SecondaryLinkText"); 110 string footerCssClass = ""; 111 string cardFooterClass = item.GetBoolean("ShowAsCard") ? "paragraph-card-footer" : "grid__cell-footer"; 112 cardFooterClass = Pageview.Device.ToString() != "Tablet" ? cardFooterClass : ""; 113 114 if (item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") { 115 footerCssClass = "grid--justify-center"; 116 } 117 118 if ((!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(linkText)) || (!string.IsNullOrEmpty(secondaryUrl) && !string.IsNullOrEmpty(secondaryLinkText))) 119 { 120 <div class="grid__cell @footerCssClass @cardFooterClass"> 121 <div class="u-margin-top u-margin-bottom"> 122 123 @if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(linkText)) 124 { 125 string buttonStyle = !String.IsNullOrEmpty(item.GetList("ButtonDesign").SelectedValue) ? item.GetList("ButtonDesign").SelectedValue : "primary"; 126 if (url.Contains("http")) 127 { 128 <a href="@url" class="btn btn--@buttonStyle dw-mod" target="_blank">@linkText</a> 129 } 130 else if (url.Contains("/")) 131 { 132 <a href="@url" class="btn btn--@buttonStyle dw-mod" download>@linkText</a> 133 } 134 else 135 { 136 <a href="@url" class="btn btn--@buttonStyle dw-mod">@linkText</a> 137 } 138 } 139 140 @if (!string.IsNullOrEmpty(secondaryUrl) && !string.IsNullOrEmpty(secondaryLinkText)) 141 { 142 string secondaryButtonStyle = !String.IsNullOrEmpty(item.GetList("SecondaryButtonDesign").SelectedValue) ? item.GetList("SecondaryButtonDesign").SelectedValue : "primary"; 143 if (secondaryUrl.Contains("http")) 144 { 145 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle dw-mod" target="_blank">@secondaryLinkText</a> 146 } 147 else if (secondaryUrl.Contains("/")) 148 { 149 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle dw-mod" download>@secondaryLinkText</a> 150 } 151 else 152 { 153 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle dw-mod">@secondaryLinkText</a> 154 } 155 } 156 </div> 157 </div> 158 } else { 159 <div class="grid__cell-footer @footerCssClass @cardFooterClass"></div> 160 } 161 } 162 163 @helper RenderText(ItemViewModel item) 164 { 165 if (!string.IsNullOrWhiteSpace(item.GetString("Text"))) 166 { 167 @item.GetString("Text") 168 } 169 } 170 171 @helper RenderModule(ItemViewModel item) 172 { 173 @Model.GetModuleOutput(); 174 } 175 176 @helper RenderImage(ItemViewModel item, bool isCarousel) 177 { 178 if (!string.IsNullOrEmpty(item.GetString("Image")) && item.GetList("ImageStyle").SelectedValue != "background") 179 { 180 string url = item.GetString("Link"); 181 182 <div class="u-margin-bottom"> 183 @if (!String.IsNullOrEmpty(url)) 184 { 185 <a href="@url"> 186 @RenderImageElement(item, isCarousel) 187 </a> 188 } 189 else 190 { 191 @RenderImageElement(item, isCarousel) 192 } 193 </div> 194 } 195 } 196 197 @helper RenderImageElement(ItemViewModel item, bool isCarousel) 198 { 199 string image = item.GetFile("Image") != null ? item.GetFile("Image").PathUrlEncoded : ""; 200 string imageFilterColor = item.GetList("ColorForTheFilter").SelectedValue != null ? item.GetList("ColorForTheFilter").SelectedValue : "none"; 201 string imageFilterPrimary = item.GetList("ImageFilterPrimary").SelectedValue != null ? item.GetList("ImageFilterPrimary").SelectedValue : "none"; 202 string imageFilterSecondary = item.GetList("ImageFilterSecondary").SelectedValue != null ? item.GetList("ImageFilterSecondary").SelectedValue : "none"; 203 string imageFilterBall = item.GetList("ImageStyle").SelectedValue == "ball" ? "image-filter--ball" : ""; 204 string altText = item.GetString("Title"); 205 string imgCssClass = ""; 206 string imgCrop = !string.IsNullOrEmpty(item.GetList("ImageCrop").SelectedValue) ? item.GetList("ImageCrop").SelectedValue : "5"; 207 bool fillCanvas = item.GetBoolean("FillCanvas") != null ? item.GetBoolean("FillCanvas") : true; 208 string fillCanvasString = fillCanvas == true ? "&amp;FillCanvas=true" : ""; 209 string imageBoxWidth = "480"; 210 int imageWidth = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 496 : 992; 211 int imageHeight = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 380 : 760; 212 string placeHolderImage = "/Files/Images/placeholder.gif"; 213 214 if (imageFilterPrimary == "colorize") { 215 imageFilterPrimary = imageFilterColor; 216 } 217 218 if (item.GetList("ContentPositions").SelectedValue == "image-centered" || item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") 219 { 220 imgCssClass = "grid__cell-img--centered"; 221 } 222 223 <div class="image image-filter image-filter--@imageFilterPrimary @imageFilterBall dw-mod js-main-image-filter"> 224 <div class="image-filter image-filter--@imageFilterSecondary @imageFilterBall dw-mod"> 225 @if (item.GetList("ImageStyle").SelectedValue == "ball") 226 { 227 imgCssClass += " grid__cell-img--ball"; 228 if (!isCarousel) 229 { 230 <img class="grid__cell-img @imgCssClass b-lazy" src="@placeHolderImage" data-src="/Admin/Public/GetImage.ashx?width=@imageBoxWidth&amp;height=@imageBoxWidth&amp;crop=@imgCrop&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=@image" alt="@altText"> 231 } 232 else 233 { 234 <img class="grid__cell-img @imgCssClass" src="/Admin/Public/GetImage.ashx?width=@imageBoxWidth&amp;height=@imageBoxWidth&amp;crop=@imgCrop&amp;Compression=75&amp;DoNotUpscale=true&amp;image=@image" alt="@altText"> 235 } 236 } 237 else 238 { 239 string largeImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&amp;height=" + imageHeight + "&amp;crop=" + imgCrop + "&amp;Compression=75" + fillCanvasString + "&amp;DoNotUpscale=true&amp;image=" + image; 240 string smallImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&amp;height=" + imageHeight + "&amp;crop=" + imgCrop + "&amp;Compression=75" + fillCanvasString+ "&amp;DoNotUpscale=true&amp;image=" + image; 241 242 if (!isCarousel) 243 { 244 <img class="@imgCssClass b-lazy" src="@placeHolderImage" data-src="@largeImage" data-src-small="@smallImage" alt="@altText"> 245 } 246 else 247 { 248 <img class="@imgCssClass" src="@largeImage" alt="@altText"> 249 } 250 } 251 </div> 252 </div> 253 } 254 255 @{ 256 string fontColor = !string.IsNullOrEmpty(Model.Item.GetList("FontColor").SelectedValue) ? "u-" + Model.Item.GetList("FontColor").SelectedValue : ""; 257 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetList("BackgroundColor").SelectedValue) ? "u-" + Model.Item.GetList("BackgroundColor").SelectedValue + "--bg" : ""; 258 string paragraphContainerClasses = ""; 259 string containerClasses = string.IsNullOrEmpty(Model.Item.GetList("Width").SelectedValue) ? "center-container dw-mod" : ""; 260 string gridClasses = "grid"; 261 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 262 263 string placeHolderImage = "/Files/Images/placeholder.gif"; 264 265 int columnCount = 0; 266 int paragraphCount = 0; 267 int totalParagraphs = Model.Item.GetItems("Paragraph").Count; 268 int totalSlides = 1; 269 270 if (Model.Item.GetList("Width").SelectedValue == "center") 271 { 272 containerClasses = fontColor + " " + backgroundColor + " center-container"; 273 containerClasses += " paragraph-container"; 274 } 275 276 if (Model.Item.GetList("Width").SelectedValue == "full") 277 { 278 containerClasses = fontColor + " " + backgroundColor; 279 } 280 281 if (Model.Item.GetList("Width").SelectedValue == "combi") 282 { 283 paragraphContainerClasses = @fontColor + " " + @backgroundColor; 284 containerClasses = "center-container paragraph-container"; 285 } 286 287 if (spacingSize == "none") 288 { 289 containerClasses += " paragraph-container--spacing-none"; 290 } 291 292 string containerBackgroundImage = ""; 293 string containerBackgroundImageSmall = ""; 294 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter").SelectedValue != null ? Model.Item.GetList("ColorForTheFilter").SelectedValue : "none"; 295 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary").SelectedValue != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 296 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary").SelectedValue != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 297 298 if (containerBackgroundImageFilterPrimary == "colorize") 299 { 300 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 301 } 302 303 if (Model.Item.GetFile("BackgroundImage") != null) 304 { 305 containerBackgroundImage = "Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded; 306 containerBackgroundImageSmall = "Admin/Public/GetImage.ashx?width=1000&amp;height=850&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded; 307 } 308 else if (string.IsNullOrEmpty(Model.Item.GetList("BackgroundColor").SelectedValue)) 309 { 310 backgroundColor = "u-color-light--bg"; 311 gridClasses += " "; 312 } 313 314 if (Model.Item.GetBoolean("SeperationLineAfter") && Model.Item.GetList("Width").SelectedValue != "center") 315 { 316 paragraphContainerClasses += " multiple-paragraphs-container--seperation-line-after"; 317 } 318 else if (Model.Item.GetBoolean("SeperationLineAfter")) 319 { 320 containerClasses += " multiple-paragraphs-container--seperation-line-after"; 321 } 322 323 // add custom height to the carousel 324 int customSliderHeight = Model.Item.GetInt32("CustomSliderHeight"); 325 int customMobileSliderHeight = Model.Item.GetInt32("CustomMobileSliderHeight"); 326 string heightCss = "height:"; 327 328 if (customSliderHeight != 0 && Pageview.Device.ToString() != "Mobile") 329 { 330 heightCss += customSliderHeight.ToString() + "px;"; 331 } 332 else if (customMobileSliderHeight != 0) { 333 heightCss += customMobileSliderHeight.ToString() + "px;"; 334 } 335 else 336 { 337 heightCss = String.Empty; 338 gridClasses += !string.IsNullOrEmpty(Model.Item.GetList("Height").SelectedValue) ? " paragraph-container--height-" + Model.Item.GetList("Height").SelectedValue : ""; 339 } 340 341 342 var isVisibleForMobile = false; 343 foreach (var paragraph in Model.Item.GetItems("Paragraph")) 344 { 345 if (paragraph.GetList("WidthMobile").SelectedValue != "hide") 346 { 347 isVisibleForMobile = true; 348 break; 349 } 350 } 351 if (Model.Item.GetItems("Paragraph").Count == 0) 352 { 353 isVisibleForMobile = true; 354 } 355 gridClasses += !isVisibleForMobile ? " u-hidden-xs u-hidden-xxs" : ""; 356 357 bool makeCentered = Model.Item.GetString("MakeParagraphsCenterAligned") != null ? Model.Item.GetBoolean("MakeParagraphsCenterAligned") : false; 358 gridClasses += makeCentered ? " grid--justify-center" : ""; 359 360 string containerId = "Paragraph_" + Model.ID; 361 string carouselContainerClass = ""; 362 string carouselSlideClass = ""; 363 364 //Set as carousel 365 if (Model.Item.GetBoolean("EnableCarousel")) 366 { 367 containerClasses += " carousel js-carousel-container carousel__paragraph-container dw-mod"; 368 carouselContainerClass += "carousel__container dw-mod"; 369 carouselSlideClass += "carousel__slide dw-mod"; 370 containerId = "Carousel_" + Model.ID; 371 } 372 373 int sliderCount = 0; 374 375 } 376 377 <div class="grid__col-md-12 grid__col--bleed"> 378 <section class="paragraph-container--full-width multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod"> 379 @if (Model.Item.GetFile("BackgroundImage") != null) 380 { 381 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod"> 382 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 383 <img class="background-image__cover dw-mod b-lazy" src="@placeHolderImage" data-src="@containerBackgroundImage" data-src-small="@containerBackgroundImageSmall"> 384 </div> 385 </div> 386 } 387 388 <div class="@containerClasses dw-mod" id="@containerId" > 389 <div class="@carouselContainerClass"> 390 <div class="@carouselSlideClass"> 391 <div class="@gridClasses dw-mod"> 392 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 393 { 394 int columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : 12; 395 396 if (columnCount < 12) 397 { 398 columnCount += columnWidth; 399 } 400 else 401 { 402 columnCount = columnWidth; 403 } 404 405 string columnCssClasses = "grid__col-sm-" + columnWidth + (paragraph.GetList("WidthMobile").SelectedValue != "hide" ? " grid__col-xs-" + paragraph.GetList("WidthMobile").SelectedValue : " u-hidden-xs u-hidden-xxs"); 406 string backgroundImage = ""; 407 string backgroundImageSmall = ""; 408 string imageStyle = paragraph.GetList("ImageStyle").SelectedValue; 409 string backgroundImageFilterColor = paragraph.GetList("ColorForTheFilter").SelectedValue != null ? paragraph.GetList("ColorForTheFilter").SelectedValue : "none"; 410 string backgroundImageFilterPrimary = paragraph.GetList("ImageFilterPrimary").SelectedValue != null ? paragraph.GetList("ImageFilterPrimary").SelectedValue : "none"; 411 string backgroundImageFilterSecondary = paragraph.GetList("ImageFilterSecondary").SelectedValue != null ? paragraph.GetList("ImageFilterSecondary").SelectedValue : "none"; 412 413 if (imageStyle == "background" && paragraph.GetFile("Image") != null) 414 { 415 columnCssClasses += " grid__col--bg"; 416 string cropMode = paragraph.GetList("ImageCrop").SelectedValue != null ? paragraph.GetList("ImageCrop").SelectedValue : "0"; 417 backgroundImage = "/Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded; 418 backgroundImageSmall = "/Admin/Public/GetImage.ashx?width=1000&amp;height=850&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded; 419 } 420 421 if (backgroundImageFilterPrimary == "colorize") 422 { 423 backgroundImageFilterPrimary = backgroundImageFilterColor; 424 } 425 426 string paragraphContainerPadding = paragraph.GetBoolean("HidePadding") ? "paragraph-container--no-padding" : ""; 427 428 <div class="@columnCssClasses paragraph-container @paragraphContainerPadding dw-mod" style="@heightCss"> 429 @if (imageStyle == "background" && paragraph.GetFile("Image") != null) 430 { 431 <div class="background-image image-filter image-filter--@backgroundImageFilterPrimary dw-mod"> 432 <div class="background-image__wrapper image-filter image-filter--@backgroundImageFilterSecondary dw-mod"> 433 <img class="background-image__cover dw-mod b-lazy" style="@heightCss" src="@placeHolderImage" data-src="@backgroundImage" data-src-small="@backgroundImageSmall"> 434 </div> 435 </div> 436 } 437 @if (Model.Item.GetBoolean("EnableCarousel") && Pageview.Device.ToString() == "Mobile") 438 { 439 <div class="carousel-rte-mobile"> 440 @RenderContent(paragraph, Model.Item.GetBoolean("EnableCarousel")) 441 </div> 442 } 443 else 444 { 445 @RenderContent(paragraph, Model.Item.GetBoolean("EnableCarousel")) 446 } 447 </div> 448 449 paragraphCount++; 450 if (paragraphCount != totalParagraphs) 451 { 452 string breakMarkup = string.Empty; 453 if (columnCount == 12) 454 { 455 breakMarkup = "</div></div><div class=\"" + carouselSlideClass + "\"><div class=\"" + gridClasses + "\">"; 456 totalSlides++; 457 } 458 @breakMarkup 459 } 460 } 461 </div> 462 </div> 463 </div> 464 465 @* disable carousel arrows *@ 466 467 @if (Model.Item.GetBoolean("EnableCarousel") && totalSlides > 1) 468 { 469 // carousel arrows 470 @*<div class="js-carousel-data" data-carousel-slide-time="@Model.Item.GetString("SlideTime")" data-slides-in-view="1"> 471 <div class="carousel-prev-btn dw-mod" onclick="Carousel.GetPreviousSlide('@containerId')"></div> 472 <div class="carousel-next-btn dw-mod" onclick="Carousel.GetNextSlide('@containerId')"></div> 473 </div>*@ 474 475 <div class="carousel-indicator-container-@containerId js-carousel-data" data-carousel-slide-time="@Model.Item.GetString("SlideTime")" data-slides-in-view="1" data-direction="horizontal"> 476 @foreach (var item in Model.Item.GetItems("Paragraph")) 477 { 478 if (sliderCount == 0) 479 { 480 <div class="carousel-bullet-@containerId active" onclick="Carousel.GoToSlide('@containerId','@sliderCount'); handleCarouselIndicators('@containerId');"></div> 481 sliderCount++; 482 } 483 else 484 { 485 <div class="carousel-bullet-@containerId" onclick="Carousel.GoToSlide('@containerId','@sliderCount'); handleCarouselIndicators('@containerId');"></div> 486 sliderCount++; 487 } 488 } 489 </div> 490 491 } 492 493 </div> 494 </section> 495 </div>