Four-level collapsing menu
|
27 posts
|
Hello, Having some problems with the Four-level collapsing menu from the navigation cookbook.
And when I click “About ABC” it will show both sub-levels.
Is there any way to match the full combination of words? |
|
1493 posts
|
This might be a job for preg_match, and mtylerb is our resident pattern-matching pro. :) I can’t get to this just now, but will check it out in the next day or two — by which time hopefully it will already be sorted! (My cunning plan.) |
|
316 posts
|
Give me a bit to play around. Busy week, sorry I haven’t been around much. ibuypink, could you list all the code you are using to create this menu? I’ll modify yours directly and then give you whatever solution I find with a bit of an explanation. |
|
27 posts
|
Here’s my code: |
|
316 posts
|
Thanks Ibuypink. I think I know where the problem lies. I’m just about to head off to work for the night, hopefully I’ll have a solution for you tomorrow, if someone doesn’t beat me to it. :-) |
|
8 posts
|
I decided that a 3 or 4 level collapsing menu wasn’t any good for me, so I wrote the following snippet that works for any number of levels, and doesn’t get confused by slug names:
It does a recursive ascent from the current page to Home (stackup function) followed by a recursive descent writing nested <ul> menus (unstack function). As I’m new to PHP the code might not be the best, but it does work. |
|
316 posts
|
Thanks peter_b! That’s actually the exact way I was heading! The only thing I might add a little later is the ability to set class=“current” to the current line item. |
|
1493 posts
|
@peter_b – very nice solution — thanks for this! It is working beautifully for me in 0.9.4. I think there are still some wrinkles to be worked out in the current 0.9.[5-to-be] version in SVN, though. Both this code and my “inline nav” code break when Frog is in a subdir. Hopefully that will be sorted before it becomes a Release Candidate, though! |
|
27 posts
|
Thanks peter_b! Just what I needed. Although, as mtylerb alreadey noted, it would be nice with a class=“current”. Is there an easy fix? |
|
8 posts
|
It’s simple to do using the built-in feature of the link() function – the second optional argument is a string to be added into the <a> tag, so setting this to ‘class=“current”’ does it. See the modified code below.
|
|
1493 posts
|
… then “Sub1 B First”, and “Sub1 B”, and “Page 1” will all be tagged with “current”. Ideally, of course, you just want the current-current :) page to have the active state! And how you do that has eluded me so far…. |
|
27 posts
|
@peter_b – Thanks! @David – I don’t really agree with you. It’s true there can only be one active page being viewed by the user, and thus only one page being the current and in your case that’s “Sub1 B Second”. But this page belongs to “Sub1 B” wich is also being viewed, since the menu folds out. And “Sub1 B” is a part of “Page 1”, also being active. And often you need to visually show the user the trail how to find the current page. |
|
1493 posts
|
@ibuypink – Yes, you’re right! I even have “multiple-current” states in another nav I built, so why I didn’t think of that … O_o … I don’t know! Meanwhile, however, I did work out how to add
The extra bit that recognizes the currently displayed page is Again, many thanks to peter_b for sorting this one out! I think it makes the “Four-level collapsing nav” in the “cookbook” obsolete! |
|
8 posts
|
Thanks for finding the bug in my code – poor testing on my part! |
|
27 posts
|
I use this navigation as the only navigation on a site and I get all the pages as a sub-level to the “Start”. Is there any way to modify this navigation, so I’ll have “Start” at the same level as “About” and “Contact”?
And also—considering other scenarios—is there a way to combine this navigation with a horizontal top-level navigation, so this navigation only will show sub-pages for the current section? |
|
8 posts
|
I’ve used the following CSS to make the top two levels look as if they’re at the same level:
So the first <ul> has zero left padding and so does the second <ul>, but the third and subsequent levels get 10px each (ie. 10px for the 3rd, 20px for the 4th, etc). I haven’t tried to mix top & side menus, as I’ve used the top position for breadcrumbs. |
|
42 posts
|
Gonna correct myself. What i mean:
Looking forward to any answers |
|
1493 posts
|
Hi Kristjan: it would be good to know a bit more about your layout, but it seems to me you want to use the unlimited levels and children in your sidebar, with the line
changed to something like
where |
|
58 posts
|
David, why you don’t see at “Translation” theme? ^^ |
|
1493 posts
|
@Ax — sorry! I don’t understand! |
|
42 posts
|
David can i have your e-mail or Msn so we can chat live sometime? Don’t want to make lots of stupid post here :P |
|
42 posts
|
David yes the unlimited levels and children i almost what i want BUT it lists me all pages i need that i shows me only child pages of section Team. Look at the layout on address www.proklubi.ee |
|
1493 posts
|
Hi Kristjan – will check into this over the weekend. But if you want email, you can use madebyfrog at gmail dot com. That will find me! :) |
|
2 posts
|
peter_b gave me a great help in a menu I’m trying to change, however, I believe there’s a problem with this structure: Home Page When I click on Sub1 B.1 to open Sub1 B.1.1, it opens and closes at the same time and I really don’t know what to do… Can anyone help me please? I want it to stay open… :( |