I have searched and searched and have come up dry. I have read the api for the menu system as well, but I can't figure out a clear cut way to print just the children of a parent of my primary links menu. Basically its structure is similar to this:
- Link 1
- Link 2
- Link 3
- Link 3.1
- Link 3.2
- Link 3.3
- Link 4
I have a page setup where there is a sidebar with my menu that only shows top-level parents(Link 1-Link 4). The Pages themselves are where the children(Link 3.1-Link3.3 on the Link 3 page) show up. I am using a nice menu module as well and it provides a function to print just part of a menu, but the problem is that it adds all of the classes of the nice menu to the lists. This is won't work because the parent menu looks radically different than the children menu. Using overrides in CSS is becoming a big pain and I know there is a better way.
So now I have been searching the internet for quite a while to find some info on how to do it. Finally I broke down and posted on the forums here to find someone who knows the drupal 6 menu system better than I do.
If any more information is needed I will gladly post it.
Comments
If you can find the mlid of
If you can find the mlid of the parent item, then you could use the following PHP to get the desired result. Not sure if there's an easier way in the API to achieve this. NOTE: I've pulled this out of a current project I'm working on, so apologies if it does not work right out of the box.
PS: Don't put this code inside a menu loader. It should work fine in theme files though.
Thanks for giving me
Thanks for giving me something to work with. Here is what I did with what you gave me.
I put the _menu_subtree_data function in my template.php, and then I put the other lines into my the body of my node. I clicked on save and it breaks the page and won't load fully. But when I click on preview, the node looks exactly like it should with the children of the parent menu item displayed where I want them displayed.
Would anyone know why this is happening? The node displays correctly in preview and not once it is saved.
The problem there, is that
The problem there, is that when the code in the node body gets eval'd, your template.php has not been loaded yet, so the _menu_subtree_data function is not available.
As I see it, you have a few options without creating a module with the above code in it:
1. Include/require your template.php in the node body before you call _menu_subtree_data().
2. Add your code in a node-[nid].tpl.php file in place of the body content.
I'm not sure which option would be best for you without knowing more about what you are trying to achieve.
Hope this is helpful.
I put this line into my
I put this line into my node.tpl.php file.
include("/sites/all/themes/lbc/template.php");
This creates a no such file error.
I first tried just template.php by itself but that gave a white screen. I am going to need to use this code on other nodes so it would not be beneficial to put it in just that one node.
You don't need to load the
You don't need to load the template.php file in node.tpl.php.
I thought you were simply using this on one node.
If you want this to work for several nodes, then you can place the above code in your node.tpl.php as is and it should work just fine.
If the mlid is always going to be the same, then you can hard code it, if not, then I might suggest putting a cck field into the node type and putting the mlid in there, and loading that up in the template.
I added the function into my
I added the function into my node.tpl.php file and now it still doesn't work, and the front page is now a blank page.
Here is the code in my node
Get first child link for given menu item
I need a way of getting the link of the first child item of a given menu item. Based on cdale's example, I wrote this function, which is working nicely. I've put this in my page.tpl.php and I'm using Drupal 6.
Hope it's useful for someone. Thanks cdale for your original example.
Site Navigation Section
http://drupal.org/project/menu_block_split
That will not work because I
That will not work because I don't need it in a block. I need it in the $content of a node. Thanks for the suggestion though.
After trying many different
After trying many different ways to get the function to be accessible to every node I resorted to putting the function into the node to see if that would work and it did. I still wish there was a way that I could have a function do this as there are other nodes that also need the function, but it looks like I am going to have to put that function into each node.