Quantcast
Channel: Using Optimizely Platforms
Viewing all articles
Browse latest Browse all 8020

Rendering multiple templates for blocks without controller

$
0
0

Hi All,

 I have requirement to render multiple templates for block with having only partial views(no controller).Currently we are using a common page for rendering some blocks.As template descriptors won't work I used IViewTemplateModelRegistrator to register multiple templates for my block.Now the problem is I can't use tag for template resolving as I'm using common page for rendering blocks.Is there any other way for template resolving.

Can someone help me in solving this issue.Please refer to the code below.

Common page to render multiple blocks:

public class OneColumnPage : HeaderBannerBase
{
/// <summary>
/// Gets or sets the main body
/// </summary>
[CultureSpecific]
[Display(
Name = "Main body",
GroupName = SystemTabNames.Content,
Order = 1)]
[AllowedTypes(new Type[]
{
typeof(TextBlock), typeof(ProductBlock), typeof(ProductTrainingBlock), typeof(PlaceBlock), typeof(TeamInfoBlock), typeof(AboutUsKeynoteBlock), typeof(AboutUsBannerBlock), typeof(AboutUsBlock), typeof(ImageGalleryBlock), typeof(GridBlock), typeof(ClaimsFormsDownloadBlock),
typeof(DocumentBlock)
})]
public virtual ContentArea MainBody { get; set; }

cshtml

@model PageViewModel<OneColumnPage>

@Html.PropertyFor(p => p.CurrentPage.MainBody, new { Tag = "_CustomContentArea" })

Code in Template Coordinator:

viewTemplateModelRegistrator.Add(
typeof(DocumentBlock),
new TemplateModel() { Name = "claimForms", Description = "Displays as claimForms.", Path = "~/Views/Shared/Blocks/DocumentBlock2.cshtml", Tags = new string[] { "claimForms" }});


Viewing all articles
Browse latest Browse all 8020

Trending Articles