My menus are like currently this:
---------------------------------------------------------
prospectus forums blogs
---------------------------------------------------------
> prospectus
- about us
- aims
- curriculum
· my account
> create content
I was hoping that when the 'about us', 'aims' and 'curriculum' pages are chosen and displayed, that the 'prospectus' link in the primary menu would stay highlighted, showing the user which 'section' they're in.
Like the beautiful menu system here: http://www.nydailynews.com
Click news, you're in the news section. Click crime, the menu shows you're clearly in the crime section. OK, Drupal can do this using primary parents and secondary children pointing to Views2 lists. What I didn't realise Drupal CAN'T do is the next part... click any story, and the menu STILL shows which section you're in, even though the menu is not pointing at a specific item now. You can go to any story on the site and the menu will show you which section you're in. Inspirational feature... Drupal core developers should take note!
I can see the same problem will happen with the forum and blogs too. As soon as the user views a node which isn't directly linked to within the menu, the whole menu will de-highlight. What an absolute piece of crap! I'm sorry, but along with the multi-language fiasco, it is. I am so sick of Drupal's stupidity in handling basic tasks.
[/rant]
Comments
If you really need the
If you really need the active state based on content type you could write your own hard coded menu block, eg :
Hydrant Ltd
www.hydrant.co.uk
Hydrant Ltd
www.hydrant.co.uk
Thanks, but that solution
Thanks, but that solution isn't possible. For one, I massively simplified the menu in the example. It would be impossible to write static menu elements for the actual thing - the menu and sections are huge. Second, admins need to be able to easily add and delete menu items using the backend, without editing code - that's why we're using a CMS.
I need to re-think the design, and start a new approach. Don't worry, it's not the first time that I've had to throw a design feature out the window and do something completely different. It's very frustrating though, especially when it isn't anything extraordinary or special. The menu system should have been able to do this easily.
This is an useful snippet
This is an useful snippet ...liked it.
Have you tried using the
Have you tried using the secondary links. You might try the following, for your primary links menu (prospectus, forums, blogs) add about us, aims, curriculum children of prospectus.
Now under Administer › Site building › Menus › Settings (a tab), set 'Source for the secondary links' to the same menu value as 'Source for the secondary links'.
Now under Administer › Site building › Blocks enable (place in a region) the 'Secondary links' block.
Thanks, I'm already using
Thanks, I'm already using that feature.
It works well if your 'section' only has 6 - 8 nodes, each node having a menu item.
Then surfing that 'section' the menu stays highlighted.
But try it with, say, the forums....
primary link = Forum
secondary links (the 'forums section') = forum1 forum2 forum3 forum4
clicking Forum => forum1 takes us to the list of posts in forum1.
Forum and forum1 are both highlighted, so we know where we are.
Confidently we click a forum post in the list and wham!
Both Forum and forum1 de-highlight and we are lost.
And it's not as if users can rely on the breadcrumb either. ;)
Drupal is perfectly capable
Drupal is perfectly capable of doing what you want--I do it on virtually every site I build with Drupal. Essentially you need to create structure within your site that goes beyond the inherent node and taxonomy system. Here's what I do:
For the purposes of discussion we'll discuss your prospectus section:
Create taxonomy vocabularies and terms. Vocabulary: prospectus; terms about us, aims, curriculum. For the vocabulary make sure you dont select Multiple select
Add terms to your nodes.
Create a view "prospectus" and assign Filters for Vocabulary term (prospectus) and Taxonomy Term (leave blank); add arguments for Taxonomy term and Node title; you'll also want to add view argument code so that when a node title is passed the view switches from 'teaser' to 'node' view.
Now, create a .tpl.php file for the name of the view you just created: maybe something like this: node-view-prospectus.tpl.php. Open node.tpl.php and copy everything from that file into your new .tpl.php file.
You'll need to add some code to find what terms are assigned to the node. I usually add a function to my template.php file that goes something like this:
Back in your node-view-prospectus.tpl.php file add this to the top of the file:
Next, comment out the part that links the title to the node and replace it with something like this:
That's the bare essentials--good luck
pp
Thanks very much for
Thanks very much for spending the time writing that walk-through.
Much appreciated.
I don't quite follow it, and could easily spend an entire day trying to get it to work.
I'm not even sure it does what I'm looking for... I can't see how it tallies with the primary/secondary menus?
You need to remember I know no php whatsoever.
But really I don't have that amount time to put into this problem; already wasted a day as it is.
I'm just going to have to workaround the menu's 'out-of-the-box' deficiency.
I was a bit upset discovering this issue, because I stupidly assumed that the menu worked just like the one on the 'NY Daily' site, just because it looked the same and seemed to act the same at first. Plus the way it *does* work is just half-arsed and illogical - it makes no sense!
I already spent weeks researching other methods of creating very defined 'sections' within the site, decided on the menu method, and spent two solid days back in September simply trying to style the menus so they would clearly show the 'sections' of the site with the highlighting (menu-trail was broken back then). So this was a very rude awakening since it greatly affects the design of the site, on top of discovering two days ago that multilanguage support for menus and blocks is absolute crap too.
It just hasn't been a good few days - the site development has gone back weeks, instead of forward. Four solid days trying to get the menu system to work, and I'm actually worse off now! I started designing this site 6 months ago. I missed my self-imposed September deadline (compared to the previous year when I built the first site with e107... I was on the beach most of the summer). Then the half-term November deadline was missed. I was really hoping to get this damn thing live for January, but with this menu problem, it's not going to happen.
If I'd known the site still wouldn't be live after 400 hours of development, I would have dumped Drupal in July (when I started researching Drupal's media handling and found it totally abysmal). I am so sick of this software. My choice to use it is truly making my life miserable at the moment; it's a never-ending nightmare of problem after problem.
lol... two rants in one day! Things must be bad!
Don't worry, I love Drupal really (and hate it).
There seems to be a module
There seems to be a module providing a neat solution for stuff like this:
http://drupal.org/project/menutrails
...but i've another menu-related question:
Is it possible, to set up primary links to dynamic sections ( respectively with parameters, like users/ ) using the standard menu system?
I've learned, that "/user" is an alias pointing to "My Account" which is actually doing the job - but unfortunately the active-trail isn't maintained causing the "My Account" link not to be highlighted when visiting /user and subsequent sections ...
Besides there are many situations, that could require context-sensitive menu items, like pointing to individual stuff of the user currently logged in...
In default navigation menu, these types of items are some kind of hardcoded and cannot be changed. Is there a way to get these things into a primary menu while keeping the active trail?
> There seems to be a module
> There seems to be a module providing a neat solution for stuff like this:
> http://drupal.org/project/menutrails
I already use menutrails to fix a styling bug in core (the secondary menu active-trail).
It doesn't solve the main issue, that both the menus de-highlight when not pointing to a specific node.
> Is it possible, to set up primary links to dynamic sections ( respectively with parameters, like users/ )
> using the standard menu system? I've learned, that "/user" is an alias pointing to "My Account" which
> is actually doing the job - but unfortunately the active-trail isn't maintained causing the "My Account"
> link not to be highlighted when visiting /user and subsequent sections
That is EXACTLY my issue. I stupidly, stupidly assumed that the menu highlighting feature in core would use wildcard strings, or taxonomy, or content-type, etc, a bit like the block visibility feature does. Eg. users/* forum/* blog/* The reason I assumed this is because menu highlighting to only one specific node is NO USE AT ALL, except perhaps on the smallest of 'static' sites.
It's like someone has seen menu highlighting on another system and thought 'cool, I'll code that for drupal core', except they haven't really understood what the other system was doing, and just superficially copied the highlighting without actually implementing the IMPORTANT part of it that allows it to be useful.
I'm angry with myself more than anything, for making an assumption that the menu highlighting was anything more than superficial.
> In default navigation menu, these types of items are some kind of hardcoded and cannot be changed.
> Is there a way to get these things into a primary menu while keeping the active trail?
Supposedly, the script posted in the thread above is something to do with that. I can't understand it though, and I don't see how it ties into the core menu system. It looks to me like it is for a hardcoded, static menu.
Script posted above
>>Supposedly, the script posted in the thread above is something to do with that. I can't understand it though, and I don't see how it ties into the core menu system. It looks to me like it is for a hardcoded, static menu.
I dont use any custom menu code or modules and get the behavior you want. You just have to learn more about drupal's capabilities and how to tap into them. The code above gives you the framework for creating custom node links which point to the view that displays them.
It ties into the menu system like this:
You create a view with a page display; (your view might get all nodes with a specific node type, or with taxonomy term "prospectus" or vocabulary name "stuff", sorted by date, etc etc)
You give the page display a path;
You create a menu item that links to the path you created for the page display;
In your view you create arguments for your view to take; an argument to take may be "taxonomy term" and "node title";
Your view receives these arguments which might modify the view query;
Example:
I created a vocabulary "photography" with terms "family," "dog," "joe," etc.
I have a view named "photography" which takes the arguments "category" and "node title" which will display the items that meet this criteria in the view. In my node.tpl.php I replace the title link with an href that looks like this:
<a href="/photography/<?php print $category; ?>/<?php print $title; ?>"><?php print $node->title; ?></a>I create sub-menu items for each category within the path I gave to my view page display; now the menu highlighting will be maintained for the parent menu and each sub-menu in that list.
I then tweak my css so that the parent list item in gets colored one color if active; each sub-item li gets another color when it's active.
The "problem" you are experiencing is that every node teaser links to the /node/* path within drupal. The code and explanation above illustrates how to override this behavior.
hope that helps--
PP
This is an incredible amount
This is an incredible amount of help. Thank you.
If it doesn't help me, hopefully your time spent will help someone else with a similar problem.
Unfortunately I cannot follow this through at the moment; I haven't time. I need to focus on getting the site up and running as quickly as I can. When it is live and stable, I'll come back and address the issue and look into your solution. As it is, I need to quickly throw something together using the block visibility; display a graphic in the header depending on url, or something similar.
Thanks very much.
My 2 cents
First off, what you want to do is possible. Secondly there is nothing wrong with the menu system. You are making invalid assumptions about how things should work, without understanding how they do work. If you know little to no php, then this can indeed be frustrating.
Menu highlighting works just fine. The problem is a lack of understanding of how and why it works as it does. If you have a menu item nested underneath another menu item the highlighting works properly yes? The problem comes in when dealing with your "theoritical" sections. If a node exists in one of your "sections" and it does not have a menu item, how do you propose that the core system "realize" that the node is in some "section"? Remember that even if you define some pretty human readable path like "/forum/my-custom-section/my-first-post", the core system still sees the node as "/node/567". You need to understand that your "sections" are just that, yours. They don't really exist anywhere as far as the menu system is concerned. There is no way for the core menu system to programmatically determine that a node theoretically exists in some section unless we give it directions on how to determine this.
Enter theme functions and the API. These exist for when we want to extend, modify or override core system behavior. It is possible using a combination of theme_menu_item, theme_menu_item_link and menu_set_location to achieve exactly what you are trying to do. I know because I have done it in the past but the code I have is for a 4.7.x drupal install. The problem is that it takes some knowledege of php and programming to implement it and understand it. Welcome to drupal. What you want is considered specialized behavior. You can tell this because the forums are not full of requests to have what you want in core.
As a last word of advice, making a post about how bad something is and stating that it is a piece of crap because of your lack of understanding and programming skill will most likely not get you a whole lot of help around here. I mean people can't even post code to you that you can understand, because what you want is not as simple as
<?php print "foo"; ?>. So a suggestion is to start learning php if you plan on wanting custom behavior from drupal.I accept what you're saying,
I accept what you're saying, and I deserve the scorn...
People with no php ability should not criticise those that do and then release their code for free.
However, I do stand by my statement. It does not make *any* sense to have the primary menu item highlight when 'forum' is clicked, have the secondary link to highlight when 'forum1' is clicked, and then for the whole thing to de-highlight when any post is read! It's useless, and worse, confusing. Other website designs instigate this type of menu perfectly, whilst the drupal version is just a bad, superficial copy.
> Remember that even if you define some pretty human readable path like
> "/forum/my-custom-section/my-first-post", the core system still sees the node as "/node/567"
Yet the block visibility feature works that way. Eg. You can use /forum* as a wildcard.
> As a last word of advice, making a post about how bad something is and stating that it is a piece of
> crap because of your lack of understanding and programming skill will most likely not get you a whole
> lot of help around here
Yes, I know. But unfortunately we are emotional beings and sometimes need to vent.
It is doubly unfortunate that the less php you know the more frustrating drupal is.
Usually I let things like this wash over me, but I actually designed the site around this assumed feature of the core menu, after discarding many other possible methods of creating clearly defined 'sections'. The site mirrors a school structure: teachers & pupils --> classes & subjects --> yeargroups --> departments --> annexes & schools - very complex. There are four schools based in two geographical annexes, and 20+ departments. The whole site is in two languages. The site needs to cater for eight year olds to sixty-five year olds, some of whom have never used a computer, yet will need to navigate and easily add media-orientated content to the site. I've been working on it for a few hours a day for six months, in addition to trying to do my normal teaching job. Yes, I snapped a little when I discovered that the menu feature I was relying on wasn't implemented properly. Apologies, but I am just human.
How about something like
How about something like this, assuming your path to the nodes below prospectus contains the word "prospectus" as the first part of the URL after .uk, the menu path for Prospectus is "prospectus", the menu path for forums is "forum", and you're using Drupal 6:
Wow... I take it you wrote
Wow... I take it you wrote that just now, especially for this thread? Thanks!
This is worth me persuing because I can *almost* understand what it's doing on a basic level.
Some questions:
1) Does this go into template.php? It's a function over-ride, right?
2)
· Will this work with urls like: domain.net/prospectus/[title]?
· Do I just need an if statement for each 'section' that has a matching url?
3)
· Will this part also work for blogs, and/or custom content types?
Thanks!!
1. Yes. Template.php.2.
1. Yes. Template.php.
2. Yes
3. If the menu link pointing to "blogs" is "blog", yes. If the "machine name" of the content type matches the string in the menu path.
This does the job but, there are more "drupally" and precise ways to do this. There's a dozen different ways to get the result. I'd suggest checking out the menu trails module someone else mentioned, too.
Thanks so much. And thanks
Thanks so much.
And thanks again to everyone who has posted scripts and solutions here.
Dare I say that the responses in this thread have even brought me out of
my latest 'drupal depression'! My original rant didn't deserve such a positive
reaction.
With alteration to my design, more emphasis on using content-types with
the menutrials module to provide 'sections', using block visibility, and with
the url script from kjl, I can envisage a solution. I also look forward to
seeing how the context module develops too.
Cheers everyone.
Enter context module?
It is truly bewildering that drupal is so poor out of the box at creating a site heirarchy as is standard on the web, at least as far as non-programmers go(some of this can probably be explained by the attitudes above >:|). However, the need is recognized by some and solutions like the context module are available. It will allow for proper menu highlighting. It's what I'm using to define sections on my site.
http://drupal.org/project/context
good luck.
awesome!
The context module looks awesome. Thanks for pointing it out. I will be monitoring its progress.
Path Auto?
Lots of good discussion and help being offered in this thread.
I have bumped into similar issues in the past. What I have come to realize is that drupal in general, and lots of its developers, don't think of web sites in terms of a typical "Section" paradigm that some of us coming from other backgrounds with other expectations have been groomed think in. A typical Drupal site is a pool of nodes of different types and views of those nodes more or less.
One method I have used in the past to build a site with a basic understanding of "sections" is to use the Path Auto module to give my different content types different paths. I can then use different content types as sections. Then figure out what section I am in by examining the path and act accordingly. This probably doesn't solve your problem, but it's one idea to think about.
Hmm, I would have liked to
Hmm, I would have liked to edit out that bit about attitudes, a bit of residual frustration stemming from my own search for this functionality a while ago, found it unnecessary after re-reading, but seems I can't edit. Please ignore it guys.
> Hmm, I would have liked to
> Hmm, I would have liked to edit out that bit about attitudes
Nah, it applies to and explains *my* attitude and rant.
And you're right that the drupal experts have been very lenient with me this time,
whilst also providing so incredibly useful resources about this issue.
Kudos to everyone for not responding with the obvious knee-jerk reaction, and
turning this from a pointless thread to a useful one.
Thanks.
I made nice_menus do exactly that...
You can see it at http://cacanational.hddigitalworks.com/, check under the "About Us" tab, choose a child menu item (it goes two levels deep), the active path lights up from the parent to the active child item. The hightlight is based on the link's uri so if you have two different item pointing to the same, both will light up. You don't have to do anything to your content, just make up the menu however you like, use nice_menus to display the menu and the highlighting just happen.
nice_menus out of the box is not capable of doing this. I have to override its themeing to make this happen.
Here is the code, if you want to use this, put this in your theme's
template.php:Solved Nice Menus Problem
Hi Mattyoung,
Your post solved my problem, I was looking for a solution to implement this in Nice Menus. I had given all hope until i came across your reply in this post( i can have a good sleep tonight :) ) thanks for the code, keep it up.
Regards,
Judef
Found this module
In my rummaging around D.O. today I found this module which I believe solves the problem in the original post.
Menu Trails can be found here --> http://drupal.org/project/menutrails
Thanks for your reply. I
Thanks for your reply.
I originally wanted the sections based on urls, using wildcards like the block visibility, to hide and display menu items or menus. To me, this would be the most flexible method. However, I decided that I had to redesign the site (physically and conceptually), and make menu highlighted 'sections' dependent on content-type. This is what menutrails does.
This is less flexible in many ways, because now my content-types have to mirror the menu items to a large extent. It's workable, although quite complex to manage many more content-types.
Further, the site is multilingual. For menutrails to work with two languages you have to add i18n variables to settings.php:
$conf['i18n_variables'] = array(
...
// Menu Trails
'menutrails_menu',
'menutrails_terms',
'menutrails_node_types'
);
the easiest stuff - and you
the easiest stuff - and you need to write something for yourself or you have to install another module :)
new menu system and i18n don't play together with primary links - sometimes you have to ask yourself, in which world of "non"-usebility the programmers are living ...