By jim0203 on
I've set my primary links as secondary links as well, so that different sets of secondary links display conditional on which primary link is selected. How can I get more control over this? Specifically, how would I make a certain set of secondary links appear when a certain node was displayed?
Comments
I'm also wondering about
I'm also wondering about this. It seems a lot of people are. Anyone got at least a hint? I can normally figure stuff out when pointed in the right direction..
We might be able to work
We might be able to work this out ourselves. I think that some function overriding is going to be called for. It's a good job I'm trying to learn PHP!
http://api.drupal.org/api/function/menu_secondary_links/6 is the function that generates the secondary links. It seems to just call http://api.drupal.org/api/function/menu_navigation_links/6, so that's where we'll be hacking about I think. As far as I can tell, it returns an array which contains all of the links which are going to be displayed in a menu.
I don't have time to look at this too closely right now, but I'm pretty certain that this is where we'll have to look. I'll post back when I've had some more time to work on this. If someone with more experience can step in to speed us up, that would be great.
One way to approach this might be via taxonomy: if a given page is of a certain category, then simulate to the functions above that it is infact another page, which has the required secondary links.
Trust me, I've been looking.
Trust me, I've been looking. Either way, it seems we're getting closer. I've had a nice breakthrough, which is good.
This will output an array which follows a trail and contain all the info of the secondary links which are under the primary link which the active page is under. If that makes sense.
I'll keep looking through the code and try to find a way to specify the which primary link you want to display the child links of, because eventually, I'll need to do that.
This is really silly
Surely Drupal should be able to do this natively? I have a feeling we're missing something, like a module which will do all this for us. Dare I say it: Joomla! is very good at this sort of thing :-).
I thought for a moment that if we used path.module (and pathauto.module) we could rename nodes so that they would be contained "within" the menu item we wanted to be active in primary links. For example, on my site I've got example.com/multimedia, which contains example.com/multimedia/audio. I tried renaming a few audio nodes to things like example.com/multimedia/audio/title-of-audio-track, expecting Drupal to work out that I wanted the primary links for "multimedia" and "audio" to appear as active (this is what I was guessing would happen from my cursory glance at the code); but it didn't work.
So, is the module out there, or should we write it?
<?php $linksarray =
This will output the links which are the children of the primary link which the current page is the child of. That's great for one of my functions, but I really need to be able to output the child links of any of my primary links. Any ideas? Anyone? It really shouldn't be this difficult. I'm almost resorting to a bunch of db_query() things, and I really can't imagine that's the best way to do it in a leading CMS.
Or, simplified: <?php print
Or, simplified:
print theme('links', $secondary_links, array('id' => 'secondarymenu'));My problem is about to be
My problem is about to be solved... Try this...
Read through that, and you'll eventually be able to do just about anything. The thing's fecking huge, and just as useful. I'm sure there's an easier way though. Seems strange to have to sift through a multidimensional array to get to anything around here.
Still, there it is. If you're not too good with arrays in PHP (and this is a biggun), then look online, as usual, there are plentiful great guides that can help you out.
EDIT: If you want to see how I got the important values out of it, let me know, and I'll post that.
I've been a bit tardy on
I've been a bit tardy on this - apologies - but does this solve the problem:
http://drupal.org/project/menu_block