My client doesn't want the parent link of a sub menu go to a page. So I thought to change the href to a hash (#). The superfish javascript generates a useful "sf-with-ul" class on the "a" element that I want to change the attribute of the href to #.
I was thinking I need something like this but I can't get it to work and don't really know at which place to insert it :
My concern is that the class "sf-with-ul" is generated through some javascript. So I don't know how if the xslt can find that? If that is the problem, how do I find that element to rewrite it in xslt?
To do the above you're thinking it would require that you got an attribute in the umbraco.config xml somewhere and it does not seem like you have that.
Seems like you're mixing JavaScript and XSLT :-) I'm pretty sure the class is added by JavaScript and is therefore accessible by JavaScript only.
Since you know that it's level 2 links you don't want links on you can for instance do a check on the level you'e at where the link is generated in your code.
Hi Jan, you're absolutely right. However I don't want to change ALL the links at level 2. How do I say only change the links that have a child list? Sorry, as you can see I really don't know my xslt syntax.
Thanks for you responses Fuji, I think its the choose/testing that I'm stuggling with as Jan pointed out.
Xslt and Superfish menu
Hullo.
My client doesn't want the parent link of a sub menu go to a page. So I thought to change the href to a hash (#).
The superfish javascript generates a useful "sf-with-ul" class on the "a" element that I want to change the attribute of the href to #.
I was thinking I need something like this but I can't get it to work and don't really know at which place to insert it :
Please could someone help me?
Here is the xslt code I got off the forums which worked for generating my menu.
Hi John,
Am not sure what you are looking for, are you trying to rewrite this
to
Yes, I'm needing this:
to be rewritten like this:
My concern is that the class "sf-with-ul" is generated through some javascript. So I don't know how if the xslt can find that? If that is the problem, how do I find that element to rewrite it in xslt?
Desired end result:
Hi John
To do the above you're thinking it would require that you got an attribute in the umbraco.config xml somewhere and it does not seem like you have that.
Seems like you're mixing JavaScript and XSLT :-) I'm pretty sure the class is added by JavaScript and is therefore accessible by JavaScript only.
Since you know that it's level 2 links you don't want links on you can for instance do a check on the level you'e at where the link is generated in your code.
So instead of having
You can write this
<xsl:choose>
<xsl:when test="@level = 2">
<xsl:value-of select="@nodeName" />
</xsl:when>
<xsl:otherwise>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</xsl:otherwise>
</xsl:choose>
I think this should work for you.
/Jan
John, Try this out
<a>
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:text>sf-with-ul</xsl:text>
</xsl:attribute>
<xsl:value-of select="@nodeName" />
</a>
//Fuji
Hi Jan, you're absolutely right. However I don't want to change ALL the links at level 2. How do I say only change the links that have a child list? Sorry, as you can see I really don't know my xslt syntax.
Thanks for you responses Fuji, I think its the choose/testing that I'm stuggling with as Jan pointed out.
No worries John, I miss undestood your request. I thought you only wanted to get this output.
I eventually found the answer!
This did the trick:
*[@isDoc]
So the full thing looked like this:
http://our.umbraco.org/forum/developers/xslt/11008-how-do-i-check-if-a-node-has-children-in-45
is working on a reply...