Error executing template "Designs/Rapido/Paragraph/ParagraphContainer.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_54a606471e644ff097e5e7e0da4b0994.Execute() in D:\dynamicweb.net\Solutions\Production\Files\Templates\Designs\Rapido\Paragraph\ParagraphContainer.cshtml:line 380
   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 @using System.Collections.Generic 3 @using System 4 @using System.Text.RegularExpressions 5 @using Dynamicweb.Core 6 @using Dynamicweb.Frontend 7 8 @functions { 9 public string GenerateRgba(string color, double opacity) 10 { 11 color = color.Replace("#", ""); 12 if (color.Length == 6) { 13 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 14 } else { 15 return Convert.ToInt16(color).ToString(); 16 } 17 } 18 } 19 20 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 21 @using Dynamicweb.Content 22 @using Dynamicweb.Frontend 23 24 @helper RenderContent(ItemViewModel item, bool isCarousel = false) 25 { 26 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : "grid__cell"; 27 cardClass = Pageview.Device.ToString() != "Tablet" ? cardClass : "grid__cell"; 28 29 string contentPosition = item.GetList("ContentPositions").SelectedValue; 30 string innerPadding = item.GetList("InnerPadding") != null ? "paragraph-container__body--padding-" + item.GetList("InnerPadding").SelectedValue : ""; 31 32 33 switch (contentPosition) 34 { 35 case "title-top": 36 <div class="@cardClass @innerPadding dw-mod"> 37 @RenderHeading(item) 38 @RenderImage(item, isCarousel) 39 @RenderText(item) 40 @RenderModule(item) 41 </div> 42 @RenderButton(item) 43 break; 44 case "image-left": 45 <div class="grid"> 46 <div class="grid__col-3"> 47 @RenderImage(item, isCarousel) 48 </div> 49 <div class="grid__col-9 @innerPadding dw-mod"> 50 @RenderHeading(item) 51 @RenderText(item) 52 @RenderModule(item) 53 @RenderButton(item) 54 </div> 55 </div> 56 break; 57 case "image-right": 58 <div class="grid"> 59 <div class="grid__col-9 @innerPadding dw-mod"> 60 @RenderHeading(item) 61 @RenderText(item) 62 @RenderModule(item) 63 @RenderButton(item) 64 </div> 65 <div class="grid__col-3"> 66 @RenderImage(item, isCarousel) 67 </div> 68 </div> 69 break; 70 case "all-centered": 71 <div class="@cardClass @innerPadding dw-mod"> 72 <div class="u-ta-center"> 73 @RenderImage(item, isCarousel) 74 @RenderHeading(item) 75 @RenderText(item) 76 @RenderModule(item) 77 </div> 78 </div> 79 @RenderButton(item) 80 break; 81 case "middle-center": 82 case "middle-left": 83 @*Part of styles is placed in Paragraph.cshtml & ParagraphContainer.cshtml*@ 84 <div> 85 <div class="@cardClass @innerPadding dw-mod"> 86 <div class="@(contentPosition == "middle-center" ? "u-ta-center" : "")"> 87 @RenderImage(item, isCarousel) 88 @RenderHeading(item) 89 @RenderText(item) 90 @RenderModule(item) 91 </div> 92 </div> 93 @RenderButton(item) 94 </div> 95 break; 96 //for "image-top" and "image-centered" 97 default: 98 <div class="@cardClass"> 99 @RenderImage(item, isCarousel) 100 101 <div class="@innerPadding dw-mod"> 102 @RenderHeading(item) 103 @RenderText(item) 104 @RenderModule(item) 105 </div> 106 </div> 107 @RenderButton(item) 108 break; 109 } 110 } 111 112 @helper RenderHeading(ItemViewModel item) 113 { 114 if (item.GetBoolean("ShowTitle") != false && !string.IsNullOrEmpty(item.GetString("Title"))) 115 { 116 string headerMargin = item.GetString("Text") != "" && item.GetString("Image") != "" ? "u-margin-bottom" : ""; 117 headerMargin = Model.GetModuleOutput() == "" ? headerMargin : "u-margin-bottom"; 118 string url = item.GetString("Link"); 119 120 if (!String.IsNullOrEmpty(url)) 121 { 122 if (item.GetBoolean("H1_Title") != false) 123 { 124 <a href="@url"> 125 <h1 class="u-no-margin h2 @headerMargin">@item.GetString("Title")</h1> 126 </a> 127 } 128 else 129 { 130 <a href="@url"> 131 <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> 132 </a> 133 } 134 135 } 136 else 137 { 138 if (item.GetBoolean("H1_Title") != false) 139 { 140 <h1 class="u-no-margin h2 @headerMargin">@item.GetString("Title")</h1> 141 } 142 else 143 { 144 <h2 class="u-no-margin @headerMargin">@item.GetString("Title")</h2> 145 } 146 147 } 148 } 149 } 150 151 @helper RenderButton(ItemViewModel item) 152 { 153 string url = item.GetString("Link"); 154 string linkText = item.GetString("LinkText"); 155 string secondaryUrl = item.GetString("SecondaryLink"); 156 string secondaryLinkText = item.GetString("SecondaryLinkText"); 157 string footerCssClass = ""; 158 string cardFooterClass = item.GetBoolean("ShowAsCard") ? "paragraph-card-footer" : "grid__cell-footer"; 159 cardFooterClass = Pageview.Device.ToString() != "Tablet" ? cardFooterClass : ""; 160 string alingClass = ""; 161 string spacing = item.GetList("InnerPadding") != null ? "paragraph-container__button--spacing-" + item.GetList("InnerPadding").SelectedValue : ""; 162 163 164 if (item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") 165 { 166 footerCssClass = "grid--justify-center"; 167 alingClass = "grid--justify-center"; 168 } 169 170 if ((!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(linkText)) || (!string.IsNullOrEmpty(secondaryUrl) && !string.IsNullOrEmpty(secondaryLinkText))) 171 { 172 <div class="grid__cell @footerCssClass @cardFooterClass"> 173 <div class="paragraph-container__button @spacing @alingClass dw-mod"> 174 175 @if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(linkText)) 176 { 177 string buttonStyle = !String.IsNullOrEmpty(item.GetList("ButtonDesign").SelectedValue) ? item.GetList("ButtonDesign").SelectedValue : "primary"; 178 if (url.Contains("http")) 179 { 180 <a href="@url" class="btn btn--@buttonStyle dw-mod" target="_blank" rel="noopener">@linkText</a> 181 } 182 else if (url.Contains("/")) 183 { 184 <a href="@url" class="btn btn--@buttonStyle dw-mod" target="_blank">@linkText</a> 185 } 186 else 187 { 188 <a href="@url" class="btn btn--@buttonStyle dw-mod">@linkText</a> 189 } 190 } 191 192 @if (!string.IsNullOrEmpty(secondaryUrl) && !string.IsNullOrEmpty(secondaryLinkText)) 193 { 194 string secondaryButtonStyle = !String.IsNullOrEmpty(item.GetList("SecondaryButtonDesign").SelectedValue) ? item.GetList("SecondaryButtonDesign").SelectedValue : "primary"; 195 if (secondaryUrl.Contains("http")) 196 { 197 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle u-margin-left dw-mod" rel="noopener">@secondaryLinkText</a> 198 } 199 else if (secondaryUrl.Contains("/")) 200 { 201 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle u-margin-left dw-mod">@secondaryLinkText</a> 202 } 203 else 204 { 205 <a href="@secondaryUrl" class="btn btn--@secondaryButtonStyle u-margin-left dw-mod">@secondaryLinkText</a> 206 } 207 } 208 </div> 209 </div> 210 } 211 else 212 { 213 <div class="grid__cell-footer @footerCssClass @cardFooterClass"></div> 214 } 215 } 216 217 @helper RenderText(ItemViewModel item) 218 { 219 if (!string.IsNullOrWhiteSpace(item.GetString("Text"))) 220 { 221 string url = item.GetString("Link"); 222 if (!String.IsNullOrEmpty(url)) 223 { 224 225 <a href="@url"> 226 @item.GetString("Text") 227 </a> 228 } 229 else 230 { 231 @item.GetString("Text") 232 } 233 234 235 236 237 } 238 } 239 240 @helper RenderModule(ItemViewModel item) 241 { 242 @Model.GetModuleOutput(); 243 } 244 245 @helper RenderImage(ItemViewModel item, bool isCarousel) 246 { 247 if (!string.IsNullOrEmpty(item.GetString("Image")) && item.GetList("ImageStyle").SelectedValue != "background") 248 { 249 string url = item.GetString("Link"); 250 251 <div class="u-margin-bottom"> 252 @if (!String.IsNullOrEmpty(url)) 253 { 254 <a href="@url"> 255 @RenderImageElement(item, isCarousel) 256 </a> 257 } 258 else 259 { 260 @RenderImageElement(item, isCarousel) 261 } 262 </div> 263 } 264 } 265 266 @helper RenderImageElement(ItemViewModel item, bool isCarousel) 267 { 268 string image = item.GetFile("Image") != null ? item.GetFile("Image").PathUrlEncoded : ""; 269 string imageNoUrlEncoded = item.GetFile("Image") != null ? item.GetFile("Image").Path : ""; 270 271 string imageFocalPointParameters = item.GetFile("Image") != null ? "&" + item.GetFile("Image").GetFocalPointParameters() : ""; 272 string imageFilterColor = item.GetList("ColorForTheFilter") != null ? item.GetList("ColorForTheFilter").SelectedValue : "none"; 273 string imageFilterPrimary = item.GetList("ImageFilterPrimary") != null ? item.GetList("ImageFilterPrimary").SelectedValue : "none"; 274 string imageFilterSecondary = item.GetList("ImageFilterSecondary") != null ? item.GetList("ImageFilterSecondary").SelectedValue : "none"; 275 string imageFilterBall = item.GetList("ImageStyle").SelectedValue == "ball" ? "image-filter--ball" : ""; 276 string altText = item.GetString("Title"); 277 278 // Get metadata for file 279 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(imageNoUrlEncoded)); 280 281 if (string.IsNullOrEmpty(altText)) 282 { 283 if (m != null) 284 { 285 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 286 switch (lang) 287 { 288 case "da": 289 altText = m.GetValue("alttext_dk"); 290 break; 291 case "de": 292 altText = m.GetValue("alttext_de"); 293 break; 294 case "fr": 295 altText = m.GetValue("alttext_fr"); 296 break; 297 default: 298 altText = m.GetValue("alttext"); 299 break; 300 } 301 } 302 } 303 304 string imgCssClass = ""; 305 string imgCrop = item.GetList("ImageCrop") != null ? item.GetList("ImageCrop").SelectedValue : "5"; 306 bool fillCanvas = item.GetBoolean("FillCanvas"); 307 string fillCanvasString = fillCanvas ? "&amp;FillCanvas=true" : ""; 308 string imageBoxWidth = "480"; 309 int imageWidth = 1240; 310 int imageHeight = 950; 311 if (item.GetList("Width").SelectedValue != "auto") 312 { 313 imageWidth = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 620 : 1240; 314 imageHeight = Int32.Parse(item.GetList("Width").SelectedValue) < 8 ? 496 : 950; 315 } 316 string placeHolderImage = "/Files/Images/placeholder.gif"; 317 318 if (imageFilterPrimary == "colorize") 319 { 320 imageFilterPrimary = imageFilterColor; 321 } 322 323 if (item.GetList("ContentPositions").SelectedValue == "image-centered" || item.GetList("ContentPositions").SelectedValue == "all-centered" || item.GetList("ContentPositions").SelectedValue == "middle-center") 324 { 325 imgCssClass = "grid__cell-img--centered"; 326 } 327 328 <div class="image image-filter image-filter--@imageFilterPrimary @imageFilterBall dw-mod js-main-image-filter @(item.GetList("ContentPositions").SelectedValue == "middle-center" ? "u-middle" : "")"> 329 <div class="image-filter image-filter--@imageFilterSecondary @imageFilterBall dw-mod"> 330 331 @if (item.GetList("ImageStyle").SelectedValue == "ball") 332 { 333 imgCssClass += " grid__cell-img--ball"; 334 if (!isCarousel) 335 { 336 <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+@imageFocalPointParameters" alt="@altText"> 337 } 338 else 339 { 340 <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+@imageFocalPointParameters" alt="@altText"> 341 } 342 } 343 else 344 { 345 string retinaImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth * 2 + "&amp;height=" + imageHeight * 2 + "&amp;crop=" + imgCrop + "&amp;Compression=75" + fillCanvasString + "&amp;DoNotUpscale=true&amp;image=" + image + imageFocalPointParameters; 346 string largeImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&amp;height=" + imageHeight + "&amp;crop=" + imgCrop + "&amp;Compression=75" + fillCanvasString + "&amp;DoNotUpscale=true&amp;image=" + image + imageFocalPointParameters; 347 string smallImage = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&amp;height=" + imageHeight + "&amp;crop=" + imgCrop + "&amp;Compression=75" + fillCanvasString + "&amp;DoNotUpscale=true&amp;image=" + image + imageFocalPointParameters; 348 349 if (!isCarousel) 350 { 351 <img class="@imgCssClass b-lazy" src="@placeHolderImage" data-src="@largeImage|@retinaImage" data-src-small="@smallImage" alt="@altText"> 352 } 353 else 354 { 355 <img class="@imgCssClass" src="@largeImage" alt="@altText"> 356 } 357 } 358 </div> 359 </div> 360 } 361 362 @{ 363 string fontColor = !string.IsNullOrEmpty(Model.Item.GetString("FontColor")) && !Model.Item.GetString("FontColor").StartsWith("#") ? "u-" + Model.Item.GetString("FontColor").Replace(" ", "-").ToLower() : ""; 364 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetString("BackgroundColor")) && !Model.Item.GetString("BackgroundColor").StartsWith("#") ? "u-" + Model.Item.GetString("BackgroundColor").Replace(" ", "-").ToLower() + "--bg" : ""; 365 string colorSettings = Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "style=\"" : ""; 366 string fontColorHex = Model.Item.GetString("FontColor").StartsWith("#") ? "color: " + Model.Item.GetString("FontColor") + ";" : ""; 367 string backgroundColorHex = Model.Item.GetString("BackgroundColor").StartsWith("#") ? "background-color: " + Model.Item.GetString("BackgroundColor") + ";" : ""; 368 colorSettings += fontColorHex; 369 colorSettings += backgroundColorHex; 370 colorSettings += Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "\"" : ""; 371 372 string paragraphContainerClasses = ""; 373 string containerClasses = ""; 374 string gridClasses = "grid "; 375 376 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 377 string placeHolderImage = "/Files/Images/placeholder.gif"; 378 int columnCount = 0; 379 int paragraphCount = 0; 380 int totalParagraphs = Model.Item.GetItems("Paragraph").Count; 381 int totalSlides = 1; 382 383 switch (Model.Item.GetList("Width").SelectedValue) 384 { 385 case "center": 386 containerClasses += "center-container paragraph-container "; 387 paragraphContainerClasses += " " + fontColor + " " + backgroundColor; 388 break; 389 case "full": 390 containerClasses += fontColor + " " + backgroundColor + " "; 391 paragraphContainerClasses += "paragraph-container--full-width "; 392 break; 393 case "combi": 394 paragraphContainerClasses += "paragraph-container--full-width " + fontColor + " " + backgroundColor + " "; 395 containerClasses += "center-container paragraph-container "; 396 break; 397 default: 398 paragraphContainerClasses += "center-container "; 399 break; 400 } 401 402 if (spacingSize == "none") 403 { 404 containerClasses += "paragraph-container--spacing-none "; 405 } 406 407 //background 408 string containerBackgroundImage = ""; 409 string containerBackgroundImagePure = ""; 410 string containerBackgroundImageLarge = ""; 411 string containerBackgroundImageMedium = ""; 412 string containerBackgroundImageSmall = ""; 413 string containerBackgroundAltText = ""; 414 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter") != null ? Model.Item.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 415 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary") != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 416 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary") != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 417 string containerBackgroundImageFilterColorCode = Model.Item.GetString("ColorForTheFilter").StartsWith("#") && containerBackgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(Model.Item.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 418 419 if (containerBackgroundImageFilterPrimary == "colorize" && !containerBackgroundImageFilterPrimary.StartsWith("#")) 420 { 421 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 422 } 423 424 if (Model.Item.GetFile("BackgroundImage") != null) 425 { 426 string focalPointParameters = Model.Item.GetFile("BackgroundImage") != null ? "&" + Model.Item.GetFile("BackgroundImage").GetFocalPointParameters() : ""; 427 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 + focalPointParameters; 428 containerBackgroundImagePure = Model.Item.GetFile("BackgroundImage").Path; 429 containerBackgroundImageLarge = "/Admin/Public/GetImage.ashx?width=1920&amp;height=845&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 430 containerBackgroundImageMedium = "/Admin/Public/GetImage.ashx?width=1024&amp;height=450&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 431 containerBackgroundImageSmall = "/Admin/Public/GetImage.ashx?width=640&amp;height=544&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 432 433 // Get metadata for file 434 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(containerBackgroundImagePure)); 435 436 if (m != null) 437 { 438 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 439 switch (lang) 440 { 441 case "da": 442 containerBackgroundAltText = m.GetValue("alttext_dk"); 443 break; 444 case "de": 445 containerBackgroundAltText = m.GetValue("alttext_de"); 446 break; 447 case "fr": 448 containerBackgroundAltText = m.GetValue("alttext_fr"); 449 break; 450 default: 451 containerBackgroundAltText = m.GetValue("alttext"); 452 break; 453 } 454 } 455 } 456 else if (string.IsNullOrEmpty(backgroundColor)) 457 { 458 backgroundColor = "u-color-light--bg"; 459 } 460 461 //separation line 462 bool haveSeparationLine = Model.Item.GetBoolean("SeperationLineAfter"); 463 if (haveSeparationLine && Model.Item.GetList("Width").SelectedValue != "center") 464 { 465 paragraphContainerClasses += "multiple-paragraphs-container--seperation-line-after "; 466 } 467 else if (haveSeparationLine) 468 { 469 containerClasses += "multiple-paragraphs-container--seperation-line-after "; 470 } 471 472 //height 473 if (!string.IsNullOrEmpty(Model.Item.GetList("Height").SelectedValue)) 474 { 475 if (Model.Item.GetList("Height").SelectedValue != "screen") { 476 gridClasses += "paragraph-container--height-" + Model.Item.GetList("Height").SelectedValue + " "; 477 } else { 478 gridClasses += " screen-height"; 479 } 480 } 481 482 if (Model.Item.GetString("MakeParagraphsCenterAligned") != null && Model.Item.GetBoolean("MakeParagraphsCenterAligned")) 483 { 484 gridClasses += "grid--justify-center "; 485 } 486 487 string containerId = "Paragraph_" + Model.ID; 488 string carouselContainerClass = ""; 489 string carouselSlideClass = ""; 490 491 //Set as carousel 492 if (Model.Item.GetBoolean("EnableCarousel")) 493 { 494 containerClasses += "carousel"; 495 containerClasses.Replace(" paragraph-container ", ""); 496 497 carouselContainerClass += "carousel__container js-carousel-slides dw-mod "; 498 499 carouselSlideClass += "carousel__slide dw-mod "; 500 501 containerId = "Carousel_" + Model.ID; 502 } 503 504 //getting video ID from youtube URL 505 bool videoIsYouTube = false; 506 string videoCode = Model.Item.GetString("VideoURL"); 507 Regex regex = new Regex(@".be\/(.[^?]*)"); 508 Match match = regex.Match(videoCode); 509 string videoId = ""; 510 if (match.Success) 511 { 512 videoId = match.Groups[1].Value; 513 videoIsYouTube = true; 514 } 515 else 516 { 517 regex = new Regex(@"v=([^&]+)"); 518 match = regex.Match(videoCode); 519 if (match.Success) 520 { 521 videoId = match.Groups[1].Value; 522 videoIsYouTube = true; 523 524 } 525 } 526 527 regex = new Regex(@"vimeo\.com\/([0-9]+)"); 528 match = regex.Match(videoCode); 529 530 if (match.Success) 531 { 532 videoId = match.Groups[1].Value; 533 videoIsYouTube = false; 534 } 535 536 } 537 538 <div class="grid__col-md-12 grid__col--bleed"> 539 <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" @colorSettings> 540 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod" @containerBackgroundImageFilterColorCode> 541 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 542 <img class="background-image__cover dw-mod b-lazy" src="@placeHolderImage" data-src="@containerBackgroundImage" data-src-small="@containerBackgroundImageSmall" data-src-medium="@containerBackgroundImageMedium" data-src-large="@containerBackgroundImageLarge" alt="@containerBackgroundAltText"> 543 @if (!string.IsNullOrEmpty(videoId) && videoIsYouTube) 544 { 545 546 <div class="video-background"> 547 <div class="video-background__container"> 548 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Model.ID)"></div> 549 </div> 550 </div> 551 } 552 else if (!string.IsNullOrEmpty(videoId)) 553 { 554 <div class="video-background"> 555 <div class="video-background__container"> 556 <div><iframe src="https://player.vimeo.com/video/@videoId?autoplay=1&byline=0&portrait=0" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe></div> 557 <script src="https://player.vimeo.com/api/player.js"></script> 558 </div> 559 </div> 560 } 561 </div> 562 </div> 563 <div class="@containerClasses dw-mod" id="@containerId"> 564 <div class="@carouselContainerClass"> 565 <div class="@carouselSlideClass"> 566 <div class="@gridClasses dw-mod"> 567 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 568 { 569 int columnWidth = 12; 570 string columnCssClasses = ""; 571 bool hideParagraph = Pageview.Device.ToString() == "Mobile" && paragraph.GetList("WidthMobile").SelectedValue.ToLower() == "hide" ? true : false; 572 573 if (paragraph.GetList("Width").SelectedValue != "auto") { 574 columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : 12; 575 576 if (columnCount < 12) 577 { 578 columnCount += columnWidth; 579 } 580 else 581 { 582 columnCount = columnWidth; 583 } 584 585 columnCssClasses = "grid__col-sm-" + columnWidth + " "; 586 } else { 587 columnCssClasses = "grid__col-auto "; 588 } 589 590 if (paragraph.GetList("WidthMobile").SelectedValue != "hide") 591 { 592 columnCssClasses += "grid__col-xs-" + paragraph.GetList("WidthMobile").SelectedValue + " "; 593 } 594 595 if (Model.Item.GetList("Height").SelectedValue == "screen") 596 { 597 columnCssClasses += " screen-height"; 598 } 599 600 string backgroundImage = ""; 601 string backgroundImagePure = ""; 602 string backgroundImageLarge = ""; 603 string backgroundImageMedium = ""; 604 string backgroundImageSmall = ""; 605 string backgroundImageAltText = ""; 606 int backgroundImageWidth = 2500; 607 int backgroundImageLargeWidth = 1920; 608 int backgroundImageMediumWidth = 1300; 609 int backgroundImageSmallWidth = 1024; 610 string imageStyle = paragraph.GetList("ImageStyle").SelectedValue; 611 string backgroundImageFilterColor = paragraph.GetList("ColorForTheFilter") != null ? paragraph.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 612 string backgroundImageFilterPrimary = paragraph.GetList("ImageFilterPrimary") != null ? paragraph.GetList("ImageFilterPrimary").SelectedValue : "none"; 613 string backgroundImageFilterSecondary = paragraph.GetList("ImageFilterSecondary") != null ? paragraph.GetList("ImageFilterSecondary").SelectedValue : "none"; 614 string backgroundImageFilterColorCode = paragraph.GetString("ColorForTheFilter").StartsWith("#") && backgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(paragraph.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 615 616 if (columnWidth < 12) { 617 backgroundImageWidth = 1250; 618 backgroundImageLargeWidth = 960; 619 } 620 621 if (imageStyle == "background" && paragraph.GetFile("Image") != null) 622 { 623 string cropMode = paragraph.GetList("ImageCrop") != null ? paragraph.GetList("ImageCrop").SelectedValue : "0"; 624 string focalPointParameters = paragraph.GetFile("Image") != null ? "&" + paragraph.GetFile("Image").GetFocalPointParameters() : ""; 625 backgroundImage = "/Admin/Public/GetImage.ashx?width=" + backgroundImageWidth + "&amp;height=1100&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded + focalPointParameters; 626 backgroundImagePure = paragraph.GetFile("Image").Path; 627 backgroundImageLarge = "/Admin/Public/GetImage.ashx?width=" + backgroundImageLargeWidth + "&amp;height=845&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded + focalPointParameters; 628 backgroundImageMedium = "/Admin/Public/GetImage.ashx?width=" + backgroundImageMediumWidth + "&amp;height=572&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded + focalPointParameters; 629 backgroundImageSmall = "/Admin/Public/GetImage.ashx?width=" + backgroundImageSmallWidth + "&amp;height=450&amp;crop=" + cropMode + "&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + paragraph.GetFile("Image").PathUrlEncoded + focalPointParameters; 630 631 // Get metadata for file 632 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(backgroundImagePure)); 633 634 if (m != null) 635 { 636 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 637 switch (lang) 638 { 639 case "da": 640 backgroundImageAltText = m.GetValue("alttext_dk"); 641 break; 642 case "de": 643 backgroundImageAltText = m.GetValue("alttext_de"); 644 break; 645 case "fr": 646 backgroundImageAltText = m.GetValue("alttext_fr"); 647 break; 648 default: 649 backgroundImageAltText = m.GetValue("alttext"); 650 break; 651 } 652 } 653 } 654 655 if (backgroundImageFilterPrimary == "colorize" && !paragraph.GetString("ColorForTheFilter").StartsWith("#")) 656 { 657 backgroundImageFilterPrimary = backgroundImageFilterColor; 658 } 659 660 string paragraphContainerPadding = paragraph.GetBoolean("HidePadding") ? "paragraph-container--no-padding" : ""; 661 string contentPosition = paragraph.GetList("ContentPositions").SelectedValue; 662 string contentPositionClasses = contentPosition == "middle-center" || contentPosition == "middle-left" ? "grid--justify-center " : ""; 663 string link1 = paragraph.GetString("Link"); 664 665 if (!hideParagraph) { 666 <div class="@columnCssClasses paragraph-container @paragraphContainerPadding dw-mod @contentPositionClasses"> 667 @if (imageStyle == "background" && paragraph.GetFile("Image") != null) 668 { 669 670 if (!String.IsNullOrEmpty(link1)) 671 { 672 <a href="@link1" style="display: block; width: 100%; height: 100%;"> 673 <div class="background-image image-filter image-filter--@backgroundImageFilterPrimary dw-mod" @backgroundImageFilterColorCode> 674 <div class="background-image__wrapper image-filter image-filter--@backgroundImageFilterSecondary dw-mod"> 675 <img class="background-image__cover dw-mod b-lazy" src="@placeHolderImage" data-src="@backgroundImage" data-src-small="@backgroundImageSmall" data-src-medium="@backgroundImageMedium" data-src-large="@backgroundImageLarge" alt="@backgroundImageAltText"> 676 </div> 677 </div> 678 </a> 679 } 680 else{ 681 682 <div class="background-image image-filter image-filter--@backgroundImageFilterPrimary dw-mod" @backgroundImageFilterColorCode> 683 <div class="background-image__wrapper image-filter image-filter--@backgroundImageFilterSecondary dw-mod"> 684 <img class="background-image__cover dw-mod b-lazy" src="@placeHolderImage" data-src="@backgroundImage" data-src-small="@backgroundImageSmall" data-src-medium="@backgroundImageMedium" data-src-large="@backgroundImageLarge" alt="@backgroundImageAltText"> 685 </div> 686 </div> 687 } 688 } 689 690 691 @RenderContent(paragraph, Model.Item.GetBoolean("EnableCarousel")) 692 </div> 693 694 paragraphCount++; 695 if (paragraphCount != totalParagraphs) 696 { 697 string breakMarkup = string.Empty; 698 if (columnCount == 12) 699 { 700 breakMarkup = "</div></div><div class=\"" + carouselSlideClass + "\"><div class=\"" + gridClasses + " dw-mod\">"; 701 totalSlides++; 702 } 703 @breakMarkup 704 } 705 } 706 } 707 </div> 708 </div> 709 </div> 710 711 @if (Model.Item.GetBoolean("EnableCarousel") && totalSlides > 1) 712 { 713 bool enableDots = Model.Item.GetBoolean("ShowDots"); 714 <script> 715 document.addEventListener("DOMContentLoaded", function () { 716 new CarouselModule("#@containerId", { 717 slideTime: @Model.Item.GetString("SlideTime"), 718 dots: @(Model.Item.GetBoolean("ShowDots").ToString().ToLower()) 719 }); 720 }) 721 </script> 722 } 723 </div> 724 </section> 725 </div>

tekst

space