Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marianne Hammer 7 posts 27 karma points
    Feb 08, 2012 @ 14:54
    Marianne Hammer
    0

    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

  • Rodion Novoselov 694 posts 859 karma points
    Feb 08, 2012 @ 15:10
    Rodion Novoselov
    0

    Hi.

    $currentPage/descendant-or-self::*[local-name() = $contenttype and @isDoc and string(umbracoNaviHide) != '1']

     

  • Marianne Hammer 7 posts 27 karma points
    Feb 08, 2012 @ 15:19
    Marianne Hammer
    0

    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?

  • Rob Watkins 369 posts 701 karma points
    Feb 09, 2012 @ 15:12
    Rob Watkins
    0

    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:

    <xmp><xsl:copy-of select="umbraco.library:GetXmlAll()"/></xmp>

    ...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.

Please Sign in or register to post replies

Write your reply to:

Draft