-
- 109 Posts
Hi,
Can anyone help with a modification to SimpleListMenu. This menus just shows the top level menus in <li>.
The modification I’m looking for is to have an "active" class on the <li> if:
1. that page is active, or
2. any children/grandchildren of that page are active.
The effect is a "sticky" section menu. If you are in the About Us section, then About Us stays highlighted, when you are in About Us, About Us > People, About Us > Company etc
Hoping someone can help...
Richard
-
- 302 Posts
The latest version of ListMenu (included below) might work for you
Basically, it identifies folders that are: opened (expanded), closed (collapsed), and pages with no children (end page). So if you were deep in a section, each "page" along the way to the page where you are would have the "expanded" class assigned to it. You could use that expanded class to do it I think.
DISCLAIMER
This was built for Etomite 0.6 - which as I keep reading, "should" work for you with modx, but you know... be careful.
Standard Disclaimer
I could be totally wrong.
I always use ListMenuX. It is very powerful; it allows you to set all kinds of parameters when you call it. And it has a "current" class for the active link; its display is controlled by CSS. I modified it slightly to also have a class "active" for the active <li> element, so you can play with background images for rounded corners.
-
- 109 Posts
Thanks All,
I am using ListMenu for L2 and deeper, but I guess I can repeat for L1. I’m guessing you can have two instances of the same Snippet in the one page.... I’ll try it and see.
Richard
You should be able to. I contributed the original ability to use multiple instances of the same snippet per page and I know it went into ListSiteMap (which starts at the specified folder and goes down vs. going up as in ListMenu). I would assume it’s in ListMenu as well.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
- 302 Posts
The only thing I know of to be careful about are the CSS IDs. You should only have one of any given ID on a page. So if there are IDs in the snippet, change them to classes (and make the appropriate adjustments in your CSS as well). After a while I started using classes exclusively so my snippets could be used multiple times on a page - even tho I rarely do that. But I can’t remember how far back I started doing that so take a peek and see!
Standard Disclaimer
I could be totally wrong.
Quote from: ricardosanX at Aug 26, 2005, 01:39 PM
Thanks All,
I am using ListMenu for L2 and deeper, but I guess I can repeat for L1. I’m guessing you can have two instances of the same Snippet in the one page.... I’ll try it and see.
Richard
I’ve got one template where I use the same menu snippet four times, with some snippets or TVs to determine the appropriate id parameter. Each one is encased in a <div> with an appropriate id and class, so I can easily manipulate the list and the links in the CSS file.
I use ListMenuX even though most of the menus are 1-level, but it has a parameter where you can specify how many levels to recurse. Was a bit of a "gotcha" the first couple of times I used it; the default level is "0", so you don’t get anything at all without setting the depth parameter! I hacked the copy that I use to make the default "1". Makes a bit more sense to me that way.
I think default of zero means unlimited depth. At least it should.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
I haven’t really examined that bit of the code, all I know is if I forget to pass a value for the parameter in the call, I don’t get any menu at all.