I have just attempted my first Xslt and I'm wondering if anyone can help with my problem.
I have a css class called active which is to change the color of the active menu item. I'm trying to get the menu item you've clicked to be marked as active and apply my css to it. However I can't seem to get it working. As I've said this is my first attempt at Xslt and I have looked around at tutorials and forums to try find a solution but I'm still having difficulty.
I have tried replacing the code in my for each loop with the suggested code above (I imagine thats were it should go) but it did not work for me. Any other ideas?
The above kind of worked, when i added my css to the ul my menu shows up.
When I hover over the Home link it lights up but when i click it it does not stay selected.
But when I hover over other items in the menu they do not light up but when i click them they do stay selected. I tried adding the span tag to the code inside the for each loop but then all items behave like the home link and light up on hover but do not stay bright once clicked.
Is this an issue with my css or am I still missing somethnig in the Xslt?
I can't seem to get the above to work, I guess I need to look at more Xslt tutorials to try get my head around them. Also before I go looking at my css and more tutorials. Would you be able to tell me were to place the above if statement in the code because it does not seem to make any difference no matter were i place it. (sorry for such a newbie question)
If you want to set a class on your first a-tag(the one that links to your homepage), when you stand on the homepage, you should change this piece of code:
Xslt menu item issue
Hey,
I have just attempted my first Xslt and I'm wondering if anyone can help with my problem.
I have a css class called active which is to change the color of the active menu item. I'm trying to get the menu item you've clicked to be marked as active and apply my css to it. However I can't seem to get it working. As I've said this is my first attempt at Xslt and I have looked around at tutorials and forums to try find a solution but I'm still having difficulty.
This is my code so far:
I have tried adding if statements etc but I have had no luck. I also had a look at: http://our.umbraco.org/forum/developers/xslt/9965-xslt-menu-problems But again I'm unsure of how to apply it to my code.
Thanks
Hi Stephen,
I think you could use the folowing code:
Cheers,
Bas
Hi Bas,
Thanks for the speedy reply!
I have tried replacing the code in my for each loop with the suggested code above (I imagine thats were it should go) but it did not work for me. Any other ideas?
Thanks again
Hi Stephen,
I did a test with the code I use for topnavigation.
Could you try this one?
Hi Bas,
The above kind of worked, when i added my css to the ul my menu shows up.
When I hover over the Home link it lights up but when i click it it does not stay selected.
But when I hover over other items in the menu they do not light up but when i click them they do stay selected. I tried adding the span tag to the code inside the for each loop but then all items behave like the home link and light up on hover but do not stay bright once clicked.
Is this an issue with my css or am I still missing somethnig in the Xslt?
Cheers for your help
Hi Stephen,
All items are working well except home. Is that correct?
We miss another bit on the home node.
<xsl:if test="$currentPage/@id =id"><xsl:attribute name="class">selected</ xsl: attribute></ xsl:if>
Otherwise it is an CSS issue.
Hi Bas,
I can't seem to get the above to work, I guess I need to look at more Xslt tutorials to try get my head around them. Also before I go looking at my css and more tutorials. Would you be able to tell me were to place the above if statement in the code because it does not seem to make any difference no matter were i place it. (sorry for such a newbie question)
Cheers
Hi Stephen
If you want to set a class on your first a-tag(the one that links to your homepage), when you stand on the homepage, you should change this piece of code:
To this:
This code will put a class="selected" on your a-tag if you currently stands on the homepage.
/Kim A
Hey Guys,
The finally code sorted everything out for me and got it all working! Thank you both very much for the help its much appreciated.
Steve
is working on a reply...