Search code examples
c1-cms

Nested Page Templates


Is it possible to nest master pages or razor views?

I was trying to get this working, and it seems like only the directly referenced template is loaded.

So if I have MasterTemplate which contains script references and the site footer, and child templates CustomerTemplate & SiteTemplate which contain the rest of the site structure, the scripts and footer aren't getting pulled in.


Solution

  • Composite C1 is relying 100% on the underlying ASP.Net technologies, so nesting masterpages or creating layouts for razor pages is done in a purely vanilla asp.net way.

    Read about it on these lins

    You might need to do some of these things through a code editor like Visual Studio though.

    Master Pages

    Create the template in C1 as usual, but afterwards you add the MasterPageFile attribute in the <%@ Master %> declaration. Let it point to another .master file you have created through Visual Studio in which you add one or more <asp:contentplaceholder /> elements. Back in your C1 template, you wrap all the content in a <asp:Content /> element, while deleting head, footer and whatever is defined in the parent master.

    Its important that you keep the Placeholder definitions in your C1 template, those you can't move to the parent master. Also make sure to put your <c1:Render /> elements inside the <asp:Content /> element.