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?
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.
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
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:
In your child template:
Hope this helps,
Tom
Thank you very much for the prompt response. I will attempt to implement this today.
is working on a reply...