Copied to clipboard

Flag this post as spam?

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


  • Paul Edwards 3 posts 30 karma points
    Jun 30, 2009 @ 12:45
    Paul Edwards
    0

    create a menu by doctype from any page

    Hi

    what i'm trying to do is create a small sub-menu of pages. i want to be able to show this menu on any page not necessarily the parent of these pages. The target pages have a specific doctype.

    I'm using the 'List subpages by document type' sample template provided however i can't figure out how to amend it to show pages of the specified doctype (no matter where they may be in the site).

    my doctypes

    Master
    ---> Home
    ---> Career

    content

    Home
    ----> Company
    -------> Careers
    ------------> Career1
    ------------> Career2

    So as you can see i want to create a submenu (macro) with links to Career1 and Career2 that i can place on any page on the site.

    Thank in advance

    Paul

  • Paul Edwards 3 posts 30 karma points
    Jun 30, 2009 @ 12:49
    Paul Edwards
    0

    found answer

    $currentPage/ancestor::root//node...

    on another post

     

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 30, 2009 @ 12:49
    Jesper Ordrup
    0

    If you create a new xslt macro from the build in "List subpages from a changable source" you get the following:

    [snip]

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>

    </li>
    </xsl:for-each>
    </ul>

    [/snip]

    Now you only need to add a content picker to the marco parameter and you're of to a great start!

    /jesper

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 30, 2009 @ 12:51
    Dirk De Grave
    100

    Hi Paul,

     

    <xsl:for-each select="$currentPage/ancestor-or-self [@level = '1']//node [@nodeTypeAlias = 'CareerAlias']">
    ...
    </xsl:for-each>

     

    should do the trick.

    Basically, you're first getting the root level node using the ancestor-or-self [@level = '1'] and then selecting all nodes which are of 'CareerAlias' document type (Replace 'CareerAlias' with the alias for the document type you're trying to iterate) using the construct:

     

    //node [@nodeTypeAlias = 'CareerAlias']

     

    (Mind the double slash '//' as this gets all nodes in the tree, regardless of there position and level in the tree)

    Hope this helps.

     

    Regards,

    /Dirk

  • Paul Edwards 3 posts 30 karma points
    Jun 30, 2009 @ 13:01
    Paul Edwards
    0

    thanks guys.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 30, 2009 @ 13:19
    Dirk De Grave
    0

    Hi Paul,

    Please mark the solution as solved so others may benefit from this!

     

    TIA,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft