My trick relies on the menu and the pages following a common directory structure. So if in your menu you had
Products
Salsa
Oven Mitts
you would have the following directory structure to go with:
products/
index.html
oven_mitts.html
salsa.html
Then, the trick is to simply traverse the URL of the current page and see if you can find a match to the parent.
So it’s not going to work on your example, because you haven’t reflected the site structure in your menu. But if you make a products folder and have an index.html in it instead of the current products.html, and then put your product_a.html and product_b.html in that folder as well, then it’s pretty simple to do (with Protaculous2):
matches = 0;
$$('#fwNav1 a').each(function(link){
if(link.readAttribute('href') == window.location.pathname){
link.addClassName('fwCurrent');
matches++;
}
});
if(matches < 1){
$$('#fwNav1 a').select(function(elm){
var link = elm.readAttribute('href');
if(link) link = link.split('?').first();
if(link && link.length > 1){
return window.location.pathname.match(
new RegExp(link)
);
}
}).invoke('addClassName', 'fwCurrent');
}
In experimenting with this, it appeared to me as though Highlight Current Page was actually doing what you want on the child pages, can’t be sure though. You should experiment with simply making the structure of the folder the way I describe, and enabling that feature on the main menu options, and see if it does do this without the added JavaScript. Otherwise, this will do the trick. Note carefully that I am relying on there being a single menu on your page, which gets named fwNav1. That number increments with each nav on the same page, so you would want to adjust your code to reflect the one you need to highlight.
Walter
On Jun 12, 2013, at 1:37 PM, Richard Cacciato wrote:
Hi Walter!
I’ve put sample pages here:
http://www.blue-iceberg.net/freeway/cssmenusample/
I want Products in the main nav to stay in the on state when you go from this page:
http://www.blue-iceberg.net/freeway/cssmenusample/products.html
to this page
http://www.blue-iceberg.net/freeway/cssmenusample/a.html
since A is a subpage of Products.
Thanks in advance.
Richard.
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options