Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Have you tried setting the TemplateTypeCategory = EPiServer.Framework.Web.TemplateTypeCategories.MvcPartial instead ?
Otherwise you might want to look at the TemplateCoordinator from the Alloy sample site.
This allows you to wire up a view to a type with a tag if you have no need for a viewmodel.
e.g. in its Register method.
viewTemplateModelRegistrator.Add(typeof(ContentPage), new TemplateModel { Name = "ContentPageWhenTag", Tags = new[] { "List" }, AvailableWithoutTag = false, Path = "~/Views/Partials/ContentPage/List.cshtml") });
It looks like you are passing a viewmodel to your view... but if you can get away with passing the page itself to the view... I would chose the template coordinator method and then you don't need to create additional controllers
regards,
Danny
I have the following code for my regular ContentPage controller
public class ContentPageController : PageController
{
public ActionResult Index(ContentPage currentPage)
{
return View(currentPage);
}
}
and this for rendering in ContentArea
[TemplateDescriptor(TemplateTypeCategory = TemplateTypeCategories.MvcPartialController, AvailableWithoutTag = false, Tags = new string[] { "List" })] public class PartialContentPageController : PageController
{
public ActionResult Index(ContentPage currentPage)
{
return PartialView("/Views/ContentPage/ListItem.cshtml", viewModel);
}
}
This is working fine if rendered like @Html.PropertyFor(m => m.MyContentArea, new { Tag = "List" }) in a page view. But, when I have the exact same code in a view for a block. The action on the PartialContentPageController don't get hit. If I set AvailableWithoutTag = true, it hits the action, but I loose the control to choose which view to use for rendering.
Functionality for tags seems to break if a page is rendered inside a ContentArea which is also rendered inside a ContentArea.
Any ideas?