Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a simple structure in my site tree.
Home
Subpage1
SubSub1
SubSub2
Subpage2
Subpage3
My XSLT is based on the standard template but I added support to display the SubSub leves in an <ul>. This works kinda almost ;)
If I browse to Home, Sub1,2,3 is displayed like it should. Browsing to Subpage1 displays SubSub1 and SubSub2 in a <ul> beneath Sub1. So far so good.
Now, if I browse to Sub2 I get Sub3 (and every other SubX) in a <ul> like the SubSub's and I can't figure out why.
Here is my XSLT.
<xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="currentPage"/> <xsl:variable name="level" select="1"/> <xsl:template match="/"> <!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="style">font-weight: bold;</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName"/> </a> </li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <ul> <xsl:for-each select="node"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:if> </xsl:for-each> </ul> </xsl:template>
Help!
/Another Fredrik
Ok, so I guessing im selecting something wrong in the
<xsl:for-each select="node">
but I can't figure out what it really should be :(
I would recommend uisng the "Cogwork Flexible Navigation" Package.
It takes a lot of stress out of simple navigtaion, like the one your trying to build.
http://our.umbraco.org/projects/cogworks---flexible-navigation
Ah, it looks great. I'll check it out. Still interested to find out what I did wrong so I can learn something :)
Hi Frederik
You could try this one out:
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::node [@level=2]" /><xsl:param name="currentPage"/> <xsl:template match="/"> <ul id="subMenu"> <!-- display normal umbraco navigation, take the tree from the active section --> <xsl:apply-templates select="$currentPage/ancestor-or-self::node [@level=2]/node [string(data [@alias='umbracoNaviHide']) != '1']"/> <li class="hide"> <p> </p> </li> </ul> </xsl:template> <xsl:template match="node[string(data [@alias='umbracoNaviHide']) != '1']" xml:space="default"> <xsl:variable name="id" select="id" /> <li class="subNiveau"> <xsl:attribute name="class">subNiveau<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> current</xsl:if><xsl:if test="$currentPage/ancestor::node[@id = $id]"> ancestor</xsl:if> </xsl:attribute> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName" disable-output-escaping="yes"/> </a> </li> <xsl:if test="count(./node) > 0 and count(descendant-or-self::node [@id = $currentPage/@id]) > 0 and ./node[@level < 5]"> <li class="subMenu2"> <ul> <xsl:apply-templates select="./node" /> </ul> </li> </xsl:if> </xsl:template>
This works for me, and I use it everytime I need a submenu on one of my sites.
/Kim A
Thanks Kim, looks quite similar to mine.
Good to hear Frederik. It could be cool if you would report back, whether your problem was solved or not.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Menu, submenu problem
I have a simple structure in my site tree.
My XSLT is based on the standard template but I added support to display the SubSub leves in an <ul>. This works kinda almost ;)
If I browse to Home, Sub1,2,3 is displayed like it should. Browsing to Subpage1 displays SubSub1 and SubSub2 in a <ul> beneath Sub1. So far so good.
Now, if I browse to Sub2 I get Sub3 (and every other SubX) in a <ul> like the SubSub's and I can't figure out why.
Here is my XSLT.
Help!
/Another Fredrik
Ok, so I guessing im selecting something wrong in the
but I can't figure out what it really should be :(
/Another Fredrik
I would recommend uisng the "Cogwork Flexible Navigation" Package.
It takes a lot of stress out of simple navigtaion, like the one your trying to build.
http://our.umbraco.org/projects/cogworks---flexible-navigation
Ah, it looks great. I'll check it out. Still interested to find out what I did wrong so I can learn something :)
Hi Frederik
You could try this one out:
This works for me, and I use it everytime I need a submenu on one of my sites.
/Kim A
Thanks Kim, looks quite similar to mine.
Good to hear Frederik. It could be cool if you would report back, whether your problem was solved or not.
/Kim A
is working on a reply...