I have a sub menu generated from a macro. I am looking to populate the
menu if a specific template is used rather than a content node.
For example. I have a template called portal. Portal can be applied to any
content textpage. In the template is a set of buttons. These buttons need to
display all the pages that use the portal template rather than displaying pages
that belong to a specific parent node.
I thought that if the templates are saved to an XML file when they are
generated then this would be simple because they would have a node id.
You can use the @template for the node of the page in question. Something like...
<xsl:if test="$currentPage/@template = 1234"> ... do something special ... </xsl:if>
As I recall, the @template is the id of the template not its alias. If you want to use the alias you'd need to write a quick little xslt extension or use some inline c# in your xslt to get the id from the template alias:
I came to this post via a search for "xslt template alias", so if anyone is interested in the code necessary to get the alias (name) of a template via XSLT, here is the code:
XSLT sub menu based on a template
Hi all,
I have a sub menu generated from a macro.
I am looking to populate the menu if a specific template is used rather than a content node.
For example. I have a template called portal. Portal can be applied to any content textpage. In the template is a set of buttons. These buttons need to display all the pages that use the portal template rather than displaying pages that belong to a specific parent node.
I thought that if the templates are saved to an XML file when they are generated then this would be simple because they would have a node id.
Is this possible?
Thanks
Roger
You can use the @template for the node of the page in question. Something like...
As I recall, the @template is the id of the template not its alias. If you want to use the alias you'd need to write a quick little xslt extension or use some inline c# in your xslt to get the id from the template alias:
cheers,
doug.
for xslt you can react on:
hth, Thomas
Thanks guys,
Is there a way of changing this:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '1']">
from documentTypeAlias to a specific document type or template? Something like documentTypeAlias=1234
Thanks
Roger
Ok, I have found in the XML the node type alias that I need:
nodeTypeAlias="dtMainPortal
am i right in thinking that this is set like:
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = dtMainPortal(data [@alias='umbracoNaviHide']) != '1']">
Thanks!
Roger
document type:
template:
my example from before had been false, it has to be the @template like Doug mentioned...
Thomas
Thanks guys. youve been a big help. I made an error with the umbracoNaviHide
This has worked perfectly:
<xsl:for-each select="$currentPage/node[@nodeTypeAlias = 'dtMainPortal']">
<li>
<a class="portal{data[@alias = 'buttonType']}" href="{umbraco.library:NiceUrl(@id)}">
<span class="btntitle"><xsl:value-of select="data [@alias = 'btnName']"/></span>
<span class="btnstrapline"><xsl:value-of select="data [@alias = 'btnStrapline']"/></span>
</a>
</li>
</xsl:for-each>
many thanks again
Roger
I came to this post via a search for "xslt template alias", so if anyone is interested in the code necessary to get the alias (name) of a template via XSLT, here is the code:
I used this in a package I just uploaded, if you want to see the whole xslt: Dynamic Body Tag
I hope this helps someone else.
~Heather
is working on a reply...