Hi,
I've got much of the functionality together that I need from Drupal, except the client would now like quite structured menu navigation and I was wondering how I would accomplish this in the least hacky way.
The site is divided up into sections with the category module, although final "pages" are often views rather than nodes, so (I think) they can't be categorised and hence put in a section directly. There's four to five layers of sections, and the end pages don't have to appear in the navigation themselves (except when they're what you'd call "index" pages).
My problems are specifically at the view layer - putting the overarching menu together in admin isn't too hard. Any suggestions on the following requirements gratefully received:
1. Across the top, two layers deep into the section hierarchy:
A B C D (Hidden dropdowns:) a1 b1 ... a2... b2... ...
2. Down the left-hand side, the second and subsequent layers of the *current* section's hierarchy. So if you're in top-level section B:
b1 b2 b2-1 b2-2... b3...
This would need to adapt depending on what section the user is navigating in (so in section A you'd just see a1...aN).
3. Current top-level-section (A, B, C or D) highlighted, and current sub-sub-...-section expanded on the left-hand side, all the way down.
I can force sections for non-sectioned pages in template.tpl.php - I'm already doing it, sort of, for one of the views - but it'd be good to know how to do the above with the least PHP. Specifically:
* how to highlight A, B, C or D (with HTML classes?) and make a menu only 2 levels deep * how to choose a submenu, and how to expand just the leaves (leafs?) that lead you down the tree to e.g. b2-3-1, given that sub-sub-sub...section (so generating a menu 2-to-X levels deep)
Many thanks in advance!
Cheers, J-P
It's hard to just give an answer when it comes to custom menus. So many things have to be factored in. ;)
Specifically:
* how to highlight A, B, C or D (with HTML classes?) and make a menu only 2 levels deep
emm >> If you are using the drupal built in menus, the structure returned by menu_primary_links() is helpful.
* how to choose a submenu, and how to expand just the leaves (leafs?) that lead you down the tree to e.g. b2-3-1, given that sub-sub-sub...section (so generating a menu 2-to-X levels deep)
emm >> choose your submenu by looking at the current node and finding its children with whatever method you have used to categorize your content (taxonomy, menu, ...)
jp.stacey@torchbox.com wrote:
Hi,
I've got much of the functionality together that I need from Drupal, except the client would now like quite structured menu navigation and I was wondering how I would accomplish this in the least hacky way.
The site is divided up into sections with the category module, although final "pages" are often views rather than nodes, so (I think) they can't be categorised and hence put in a section directly. There's four to five layers of sections, and the end pages don't have to appear in the navigation themselves (except when they're what you'd call "index" pages).
My problems are specifically at the view layer - putting the overarching menu together in admin isn't too hard. Any suggestions on the following requirements gratefully received:
Across the top, two layers deep into the section hierarchy:
A B C D (Hidden dropdowns:) a1 b1 ... a2... b2... ...
Down the left-hand side, the second and subsequent layers of the
*current* section's hierarchy. So if you're in top-level section B:
b1 b2 b2-1 b2-2... b3...
This would need to adapt depending on what section the user is navigating in (so in section A you'd just see a1...aN).
- Current top-level-section (A, B, C or D) highlighted, and current
sub-sub-...-section expanded on the left-hand side, all the way down.
I can force sections for non-sectioned pages in template.tpl.php - I'm already doing it, sort of, for one of the views - but it'd be good to know how to do the above with the least PHP. Specifically:
- how to highlight A, B, C or D (with HTML classes?) and make a menu only 2 levels deep
- how to choose a submenu, and how to expand just the leaves (leafs?) that lead you down the tree to e.g. b2-3-1, given that sub-sub-sub...section (so generating a menu 2-to-X levels deep)
Many thanks in advance!
Cheers, J-P
Hi,
Thanks very much for your reply:
- how to highlight A, B, C or D (with HTML classes?) and make a
menu only 2 levels deep
emm >> If you are using the drupal built in menus, the structure returned by menu_primary_links() is helpful.
That looks almost ideal, actually. I've had to use it as a stub for my own, but it's pretty much the mechanism I'm looking for.
The problem I'm having is that frequently I have items which have a natural place in the notional hierarchy of my site, but no entry in the menus. So there's a trail through open menus that ought to all be open, but they're not (because the specific bit of the menu that the page "feels like" it falls under isn't the current active item).
While it's possible to fudge things a *bit* with the category module, that only works for quasi-static pages: I can't seem to categorise e.g. views or the site shop. So I'm currently wrapping my call to menu_tree() with a temporary hack to the active item:
$temp = $_GET['q']; menu_set_active_item(myfunc_map_to_effective_active_item($temp));
/* Menu functions go here, unaware of the hack */
menu_set_active_item($temp);
It all seems to work, though it feels a bit hairy.
Cheers, J-P
if you views are displaying as a page, you could enable the menu feature on then move it under the correct parent. I do feel your pain, there always seems to be one page that breaks whatever menu I've come up with ;)
On 5/9/07, J-P Stacey jp.stacey@torchbox.com wrote:
Hi,
Thanks very much for your reply:
- how to highlight A, B, C or D (with HTML classes?) and make a
menu only 2 levels deep
emm >> If you are using the drupal built in menus, the structure
returned by menu_primary_links() is helpful.
That looks almost ideal, actually. I've had to use it as a stub for my own, but it's pretty much the mechanism I'm looking for.
The problem I'm having is that frequently I have items which have a natural place in the notional hierarchy of my site, but no entry in the menus. So there's a trail through open menus that ought to all be open, but they're not (because the specific bit of the menu that the page "feels like" it falls under isn't the current active item).
While it's possible to fudge things a *bit* with the category module, that only works for quasi-static pages: I can't seem to categorise e.g. views or the site shop. So I'm currently wrapping my call to menu_tree() with a temporary hack to the active item:
$temp = $_GET['q']; menu_set_active_item(myfunc_map_to_effective_active_item($temp)); /* Menu functions go here, unaware of the hack */ menu_set_active_item($temp);It all seems to work, though it feels a bit hairy.
Cheers, J-P -- [ Drupal support list | http://lists.drupal.org/ ]