I currently have a "hard coded" menu on my site, hence there is no XSLT related to this menu (it had to be this way due to the design and custom classes associated with the navigation).
But I need to add a ".current" class onto the nav item which refers to which page I am currently viewing. For example, when Im on my home page, then nav bar will generate this:
[code]
Home
Contact
etc...
[/code]
Is there anyway to do this? Any help would be great.
depending on the hardcoded menu and your page-structure, you could use jquery to add a class to your li.
But that all depends whether you can determine a link between the page and the menu. If your menu is hardcoded, I doubt it is easy to accomplish...
There is no way you can build the menu using xslt? From the example you posted, it looks completely possible to me.
I suppose I could do this, if the XSLT could just simply display similar HTML to what I posted above. I'm new to umbraco and xslt so I'm not really sure how to do basic stuff, I've just sort of followed the tutorials on umbraco.tv! Can I just create an XSLT macro that contains simple HTML and then insert a macro?
Yes, you can use xslt to create a nice menu like you 'hardcoded'.
If you use xslt, your menu will automagically be extended if a user adds a new page to the site. If you hardcode your menu, it won't.
To have a play, go to the developer-section and create a new xslt. Instead of a 'clean' file, take a look at all the other examples you can use.
You then insert that macro in a template and voila, the html that is created by the xslt will be shown.
Hope this helps a bit more and if you have more questions, just ask!
The point of this hard coded is menu, is that new pages don't get added on when created - due to the nature of the site - it has a specific amount of pages and we dont want menus adding on - so is it possible to actually just enter the html for the nav items I already for example:
[code]
Home
About
Contact
[/code]
This would be the xslt file with hard coded items in. Then I insert the macro in the template. If I did it this way - would I still be able to associate the page with the nav item itself - in order to add the .current class?
Apologies - I know this is a silly way of doin a nav - but it's the nature of the site!
Current page css class
Hi guys,
I currently have a "hard coded" menu on my site, hence there is no XSLT related to this menu (it had to be this way due to the design and custom classes associated with the navigation).
But I need to add a ".current" class onto the nav item which refers to which page I am currently viewing. For example, when Im on my home page, then nav bar will generate this:
[code]
etc...
[/code]
Is there anyway to do this? Any help would be great.
Cheers, Garry.
Garry,
depending on the hardcoded menu and your page-structure, you could use jquery to add a class to your li.
But that all depends whether you can determine a link between the page and the menu. If your menu is hardcoded, I doubt it is easy to accomplish...
There is no way you can build the menu using xslt? From the example you posted, it looks completely possible to me.
HTH,
PeterD
Hi Peter,
I suppose I could do this, if the XSLT could just simply display similar HTML to what I posted above. I'm new to umbraco and xslt so I'm not really sure how to do basic stuff, I've just sort of followed the tutorials on umbraco.tv! Can I just create an XSLT macro that contains simple HTML and then insert a macro?
Thanks for the swift reply!
Yes, you can use xslt to create a nice menu like you 'hardcoded'.
If you use xslt, your menu will automagically be extended if a user adds a new page to the site. If you hardcode your menu, it won't.
To have a play, go to the developer-section and create a new xslt. Instead of a 'clean' file, take a look at all the other examples you can use.
You then insert that macro in a template and voila, the html that is created by the xslt will be shown.
Hope this helps a bit more and if you have more questions, just ask!
Cheers,
PeterD
The point of this hard coded is menu, is that new pages don't get added on when created - due to the nature of the site - it has a specific amount of pages and we dont want menus adding on - so is it possible to actually just enter the html for the nav items I already for example:
[code]
[/code]
This would be the xslt file with hard coded items in. Then I insert the macro in the template. If I did it this way - would I still be able to associate the page with the nav item itself - in order to add the .current class?
Apologies - I know this is a silly way of doin a nav - but it's the nature of the site!
Garry.
You can modify your xslt like this, but it is far from ideal :-)
Petr
Thats Petr, thats exactly what I needed - thanks very much.
I'm glad it works :-).
Petr
is working on a reply...