Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Controller with TemplateDescriptor for Block without Controller not working.

Vote:
 

Hi, I have a Block without controller. I want to create a Tag based contoller using TemplateDescriptor feature. This is code for the controller with tag.

[TemplateDescriptor(
    AvailableWithoutTag = false,
    ModelType = typeof(FaqBlock),
    Tags = new[] { CmsFeatureTemplateTags.ProductFaqs })]
public class FaqBlockProductFaqsController : BlockController<FaqBlock>
{
    public override ActionResult Index(FaqBlock currentContent)
    {
        return this.View("~/Views/Content/FaqBlock/ProductFaqs.cshtml", currentContent);
    }
}

Here Tag name value is

  public const string ProductFaqs = "ProductFaqs";

View template for the default block is working, but when I created a controller with TemplateDescriptor the controller is not hitting.

Here I added Tag to render that, this isn't hitting controller with Tag and not event rendering the default view template.

@Html.DisplayFor(x => Model.ContentArea, new { Tag = CmsFeatureTemplateTags.ProductFaqs})

Any thoughts?

#208270
Oct 18, 2019 14:29
Vote:
 

Hi Praful, 

Try using a PropertyFor instead of DisplayFor - that should fetch the correct template from the TemplateDescriptor settings you have provided. 

Thanks,

Paul 

#208280
Oct 18, 2019 17:18
Vote:
 

Hey Paul, thanks for the reply.

Sorry for the confusion. Actual both (PropertyFor() & DisplayFor()) were working. The actual issue I figured out was backend logical mistake. we have same content area proeprties on current and parent product. We are fatching the parent as fallback (if currnent product's property is empty). We had a logical mistake in code that it was not including the current product to see the item in content area and only included the parent. And in cms the parent's content area was empty.

My bad :(

Apologies for the confusion.

#208297
Oct 20, 2019 5:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.