Search the FirstSpirit Knowledge Base
In an existing project there are various page templates with the same navigation function.
<CMS_HEADER>
...
<CMS_FUNCTION name="Navigation" resultname="page_nav">
...
</CMS_FUNCTION>
...
</CMS_HEADER>
...
$CMS_VALUEpage_nav)$
...
What is to be done to centralize the navigation function to avoid redundant code and to access it by the templates with an adequate call?
Instead of calling the $CMS_VALUE()$ inside the format template, add the attribute 'context="PAGE"' to your header function and add the corresponding $CMS_RENDER()$ statement to the output channel of your page template (as early as possible, ideally directly after the header declaration). The results of the header function are then set to your page context and can be individually called just as if the functions were defined in the header of the page template itself.
You can add several functions to one format template this way.
Hello Mr. Schmidt,
you can use a format template (Formatvorlagen) like "myNavigation" and put inside your code:
<CMS_HEADER>
...
<CMS_FUNCTION name="Navigation" resultname="page_nav">
...
</CMS_FUNCTION>
...
</CMS_HEADER>
$CMS_VALUEpage_nav)$
In your page templates (Seitenvorlagen) you call this format template like that:
$CMS_RENDER(template:"myNavigation")$
Hope, it'll help.
C. Klingbeil
Hey C. Klingbeil,
thanks for the reply. The solution above works fine. But I'd rather have preferred a solution where I can combine multiple function declarations, e.g. for a main navigation, a secondary navigation and something else within one single template object.to be included by each page. As far as I understand it, this would not be possible with the approach above as the $CMS_RENDER requires the $CMS_VALUE(...)$ within the rendered template object to do something useful.
Regards
Michael
Instead of calling the $CMS_VALUE()$ inside the format template, add the attribute 'context="PAGE"' to your header function and add the corresponding $CMS_RENDER()$ statement to the output channel of your page template (as early as possible, ideally directly after the header declaration). The results of the header function are then set to your page context and can be individually called just as if the functions were defined in the header of the page template itself.
You can add several functions to one format template this way.
Dear Andreas,
that's what I looked for. Thank you.
regards
Michael