accordion menu Options
Nicky
Posted: Friday, June 27, 2008 4:23:19 PM

Rank: Newbie

Joined: 6/27/2008
Posts: 11
Location: Antwerp, Belgium
Trying to make an accordion menu with 1 sub level but I'm kind of stuck, i got the following content tree:
Code:

-|Main
--|Home
--|About
---|item1
---|item2
--|contact


and i've got the following xslt:

Code:

<xsl:param name="currentPage"/>

<xsl:template match="/">

<ul>   
    <xsl:for-each select="$currentPage/ancestor::root/node[@nodeName='Main']/node">

        <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
            <xsl:if test="$currentPage/@id=current()/@id">
                <ul>
                <xsl:for-each select="current()/node">
                    <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
                </xsl:for-each>
                </ul>
            </xsl:if>
        </li>

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

</xsl:template>


now when i activatenothe i get the 3 items, when i click Home it makes "about" and "contact" his subitems

when i click "about" i get the correct foldout
and when i click contact it shows the 3 1st lvl items as it should...

can any1 point me in the right direction?

When you find yourself on the side of majority, it's time to pauze and reflect
Dirk
Posted: Friday, June 27, 2008 10:22:16 PM

Rank: Fanatic

Joined: 9/27/2007
Posts: 403
Location: Belgium
Hi Nicky,

Here's what I could come up with:

Code:
<ul>   
    <xsl:for-each select="$currentPage/ancestor::root/node[@level = 1]/node">
        <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>(<xsl:value-of select="@id"/>)
            <xsl:value-of select="$currentPage/@id"/>
            <xsl:if test="($currentPage/@id=current()/@id and count(current()/node) > 0) or ($currentPage/@parentID = ./@id)">   
                <ul>
                <xsl:for-each select="current()/node">
                    <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
                </xsl:for-each>
                </ul>
            </xsl:if>
        </li>
    </xsl:for-each>
</ul>


Hope that helps
/Dirk


level 1 certified - umbraco blog at netaddicts.be
Nicky
Posted: Monday, June 30, 2008 11:30:52 AM

Rank: Newbie

Joined: 6/27/2008
Posts: 11
Location: Antwerp, Belgium
Thx a lot, works like a charm, I edited a little bit to make it suite my needs, here's my end result:
Code:

<ul>   
    <xsl:for-each select="$currentPage/ancestor::root/node[@nodeName='Main']/node">
        <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
            <xsl:if test="($currentPage/@id=current()/@id and count(current()/node) > 0) or ($currentPage/@parentID = ./@id)">   
                <ul>
                <xsl:for-each select="current()/node">
                    <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
                </xsl:for-each>
                </ul>
            </xsl:if>
        </li>
    </xsl:for-each>
</ul>


When you find yourself on the side of majority, it's time to pauze and reflect
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.