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: Umbracoholic

Joined: 9/27/2007
Posts: 1,136
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 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
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
Claushingebjerg
Posted: Wednesday, August 27, 2008 9:36:22 PM

Rank: Enthusiast

Joined: 8/26/2008
Posts: 26
Location: Denmark
How would one go about changing this xslt to do the following:

Item1
Item2
Item3

The user clicks item2

Item1
Item2
..|-subitem1
..|-subitem2
Item3

The user then clicks subitem 1

Item1
Item2
..|-subitem1
....|-subsubitem1
....|-subsubitem2
....|-subsubitem3
..|-subitem2
Item3

And so forth. I've been trawling this forum and other sites all night, but i cant seen to figure it out.

So any help will be appreciated. And yes im a newbie :)
ak
Posted: Wednesday, December 31, 2008 1:10:10 AM
Rank: Newbie

Joined: 12/30/2008
Posts: 3
Location: Australia
Have you had any success with the above?? I'd like to do the same.
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.