Copied to clipboard

Flag this post as spam?

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


  • Roger 195 posts 474 karma points
    Feb 28, 2013 @ 11:49
    Roger
    0

    XSLT Sub Menu Help Please

    Hi all,

    I have a main page that has child pages:

    >Homepage
    >>Courses (parent)
    >>>Course1 (child)
    >>>Course2 (child)
    >>>Course3 (child)

    etc etc

    In the parent page template is a macro with a sub menu to list all child pages. This works fine. However, I would like the child pages to have the same menu and show the other children so the user doesnt have to go back to the parent page to access the sub menu. Here is my sub menu:

    <ul>
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:attribute name="title"><xsl:value-of select="@nodeName"/></xsl:attribute>
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    Any help would be great, thanks

    Roger

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Feb 28, 2013 @ 12:24
    Alex Skrypnyk
    0

    Hi Roger,

    Do you need to select siblings when you are on the child pages? 

    Alex

  • Roger 195 posts 474 karma points
    Feb 28, 2013 @ 14:27
    Roger
    0

    Hi alex,

    Basically I need the sub menu to only ever show the children on the same level as the page selected.

    Just in case the user wants to add a page to the child, the menu needs to work right down the heirarchy:

    >Homepage
    >>Courses (parent)
    >>>Course1 (child) SELECTED - Course1 page would still show itself and the other 2 children
    >>>Course2 (child)
    >>>Course3 (child)

    Also on a deeper lever:

    >Homepage
    >>Courses (parent)
    >>>Course1 (child)
    >>>>>>Sub Course1>>>Sub Course1 (child/child) SELECTED - Sub Course1 page would still show itself and the other 2 children
    >>>>>>Sub Course2
    >>>>>>Sub Course3
    >>>Course2 (child)
    >>>Course3 (child)

    I hope this makes sense?

    I have put together a temprary solution but it is limited to a certain level:

    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="2"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=2 and @isDoc]/*[@isDoc and string(umbracoNaviHide) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                 <xsl:if test="@id = $currentPage/@id">
                        <xsl:attribute name="class">selected</xsl:attribute>
                  </xsl:if>
                <xsl:attribute name="title"><xsl:value-of select="@nodeName"/></xsl:attribute>
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    But this is a problem if the user wants to add more sub pages, then the levl would be 3/4/5 etc and this solution is limited to level 2

    Thanks

    Roger

  • Ipangh 1 post 21 karma points
    Jun 30, 2014 @ 06:18
    Ipangh
    0

    hey roger i have a same problem with you, can you tell me what must i do? thanks before

     

    **sorry for my bad english (:

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 30, 2014 @ 07:57
    Dennis Aaen
    0

    Hi Ipangh,

    I will try to help you out here. What if you´re doing something like this? Does it do what you want then. If not please don't hesitate to ask anything further :-)

    <xsl:param name="currentPage"/>
    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc]/*[@isDoc and string(umbracoNaviHide) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                 <xsl:if test="@id = $currentPage/@id">
                        <xsl:attribute name="class">selected</xsl:attribute>
                  </xsl:if>
                <xsl:attribute name="title"><xsl:value-of select="@nodeName"/></xsl:attribute>
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft