Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Drew Llewellyn 2 posts 22 karma points
    Dec 16, 2011 @ 15:34
    Drew Llewellyn
    0

    Adding content to child templates

    I have a master template which displays the page. I have sub-templates for different document types. To give an example of the problem I’ll reference one specifically which is a Gateway Page. This is the same as a regular page, except at the bottom of the content it will also list all the child-node pages of that page.


    At the moment the master template goes as follows (in pseudo-code)

    Some HTML

    Page Content

    Gateway Page Macro

    Some HTML


    The gateway page macro checks if the document type is ‘Gateway Page’ and if so, shows the child nodes.

    This works, but is inefficient. Every page runs the macro, when actually only gateway pages need to run the macro, and in that case the macro wouldn’t need to do a logic check to see if it’s the correct type.

    The Gateway Page template is empty, because I’m unclear as to how/where it gets used in the master template.


    In what way would I need to restructure the code in Templates so that the macro is only called in Gateway Pages?

    Thanks for your assistance,

    Drew

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 16, 2011 @ 15:54
    Tom Fulton
    0

    Hi Drew,

    What you should do is add a ContentPlaceHolder to your NesscoMaster template, and reference that in your Gateway Page template and render the macros inside there.  That way it will only render on the Gateway Page template (that's what you want, right?)

    I usually add a placeholder called ContentBelow below the "main" content, so in my child templates I can easily append content at the bottom.  I also wrap the main content in a StandardContent placeholder and define the default content in my master template, so that I can override it in child templates as needed.

    Ex:

    <div id="mainBody">
        <asp:ContentPlaceHolder Id="StandardContent" runat="server">
              <umbraco:Item field="umbHeadline" insertTextBefore="&lt;h1&gt;" insertTextAfter="&lt;/h1&gt;" runat="server" />
              <umbraco:Item field="bodyText" runat="server" />
            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder Id="ContentBelow" runat="server"/>
    </div>

    In your child template:

    <asp:Content ContentPlaceHolderId="ContentBelow" runat="server">
        Put your macro here
    </asp:Content>

    Hope this helps,
    Tom

  • Drew Llewellyn 2 posts 22 karma points
    Dec 19, 2011 @ 13:49
    Drew Llewellyn
    0

    Thank you very much for the prompt response. I will attempt to implement this today.

Please Sign in or register to post replies

Write your reply to:

Draft