I'm trying to create a listing thats displays all content under the current page of a certain doctype (article, blog, review). In my macro i've added a parameter "contenttype" that's a contenttype id. And now for the question:
How do i convert the content type id i get from the macro, into something usefull in a for-each statement?
<ul> <xsl:for-each select="$currentPage/descendant-or-self::*/ CONTENTTYPE SHOULD GO HERE [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each>
Looks like @nodeType contains the document type ID, which is what I assume you mean by content type?
So try:
$currentPage/descendant-or-self::*[@nodeType= $contenttype and string(umbracoNaviHide)!='1']
I removed the @isDoc check - if you are checking the @nodeType you shouldn't need it.
I just printed out the document tree in the XSLT editor to find this - if you haven't done that before, just create an XSLT file where the main template is simply:
How to use dynamically content type from macro
Hi
I'm trying to create a listing thats displays all content under the current page of a certain doctype (article, blog, review). In my macro i've added a parameter "contenttype" that's a contenttype id. And now for the question:
How do i convert the content type id i get from the macro, into something usefull in a for-each statement?
My code so far:
<xsl:variable name="contenttype" select="/macro/contenttype"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="$currentPage/descendant-or-self::*/ CONTENTTYPE SHOULD GO HERE [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
Thanks
Marianne
Hi.
Thanks for your answer but no luck with that solution.
$contenttype is still an id of the content type selected and local-name is the name of the selected type.
Any suggestions on how to convert content type id to the "name" version of the content type?
Looks like @nodeType contains the document type ID, which is what I assume you mean by content type?
So try:
I removed the @isDoc check - if you are checking the @nodeType you shouldn't need it.
I just printed out the document tree in the XSLT editor to find this - if you haven't done that before, just create an XSLT file where the main template is simply:
...and run the "Visulaize XSLT".
It's quite hard to read but you can Google for online XML formatters to paste it into if you can't see what you need straight away.
is working on a reply...