How to get information from a called template to the top of the page
This is an open discussion with 2 replies, filed under XSLT.
Search
please have a lock at: https://github.com/germchaos/workspace/blob/master/utilities/html-head-metas.xsl
and have in mind: a varibale once defined oin xsl could not be overwritten. so is does noit matter whether you define some variables in your page tempalte or not as loang as you define deafults in your (modified?) xslt-util.
This has been answered before.
Use the mode
feature.
In your master template you can use
<head> ~head stuff~ <xsl:apply-templates mode="head"/> </head> <body> <xsl:apply-templates/> </body>
At the bottom of your master, add this
<xsl:template match="data" mode="head"> ~default stuff or leave empty~ </xsl:template>
in case your page does not have specific head content. Otherwise your XSLT will break.
Now on any page, you can add
<xsl:template match="data" mode="head"> ~stuff to go in your head~ </xsl:template> <xsl:template match="data"> ~regular body stuff~ </xsl:template>
mode
can be anything, so you can have one for your footer, sidebar, etc.
Create an account or sign in to comment.
Hi,
I've got a fairly complex problem. At least to explain. Any advice is welcome!
I have a template in Pages/Home.xsl that calls Utilities/Master-template.xsl. This master template then applies other templates, based on the current page-type. I want to set a variable in the template for the page-type, like a header-title-tag or other meta-information, and use that variable in the top of the master-template. How can I get the information there?
Example of the master-template.xsl:
Thanks!