By mtokoly on
Drupal 7.x
I have created several basic pages and i would like to show some of them as sub links, this is currently what i have:
<div id="header-nav">
<?php if ($main_menu): ?>
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'nav-links',
),
)); ?>
<?php endif; ?>
</div>
However, it only displays the top level menu items. How can i display the top and lower level links?? I would like to achieve:
<ul>
<li>
Example Top Level
<ul>
<li>Example Second Level</li>
</ul>
</li>
</ul>
Comments
Same here!
In the base template stark, I tried:
<?php print_r($main_menu); ?>, and $main_menu doesn't carry any of the sub link items I created... Maybe a remaining bug?I'm relatively new to Drupal so I'm not really sure if we should create an Issue for that...? I might miss something. Just in case: http://drupal.org/node/add/project-issue/drupal.
Maybe a similar problem / solution
Check http://drupal.org/node/784996
Hierarchical main menu in Drupal 7 theme
You can show sub menu items adding next function to template.php:
Don't forget to change function name 'your_teme'
Also this module could be helpful:
http://drupal.org/project/menu_block
hook_links?
Where are you finding this hook? There doesn't seem to be a hook called hook_links()...
It's not a hook, it's a theme
It's not a hook, it's a theme function (theme_links()) that you can override.
Contact me to contract me for D7 -> D10/11 migrations.
Same Problem, No solutions
I have been searching for hours now and found no solution to this yet. If anyone knows how to achieve this please link to the solution.
There are very detailed
There are very detailed instructions at http://deltup.org/page.php?4/bartik to create drop-down menus in Bartik theme, which you should be able to adapt to any theme.
Show as expanded
Check You have selected "Show as expanded" while creating the Parent menu. This is the most common error happening for parent-child menu items.
This is a simplified version
I wish I could delete my post - I realise now that it's probably not very relevant to v7. Might be useful to someone using v6.
This is a simplified version of how I themed my menus (in Drupal 6.15):
page.tpl.php:
menu_tree.tpl.php:
menu_item.tpl.php:
menu_item_link.tpl.php:
A more advanced version of menu_tree.tpl.php - my submenu markup was different to the top-level menu so I changed includes/menu.inc and includes/common.inc (not recommended) to pass in the level of the menu and the parent link:
menu_tree.tpl.php:
changes to menu.inc:
changes to common.inc:
Mark, hacking drupal core
Mark, hacking drupal core files is very bad idea anyway.
Cheers,
Andrey
Drupal Sites Showcase. Add yours! | My Blog
subscribing
Same here...
Use Menu Block module!
After quite a while I stumbled over this module that fixes the problem (D7):
http://drupal.org/project/menu_block
The other way to solve it:
The other way to solve it:
Create a region for menu (if there are no suitable yet) and then just enable main links block there. This will hopefully will be the only way for D8, but I use this technique starting from D5. Works like charm.
UPD: of course you'll have to style that menu block.
Cheers,
Andrey
Drupal Sites Showcase. Add yours! | My Blog
simple D6 solution
I found this thread when I came upon the same issue in Drupal 6. (I'm assuming "main menu" in D7 is the equivalent of "primary links" in D6.) Here's my solution in case anyone can make use of it:
1) Define a custom theme hook (template.php)
2) Implement the output function (template.php)
3) Use it (probably in page.tpl.php)
Sub Menu links not showing in main menu
Have sub menu items added dynamically with menu_link_save but links not visible.
Tried switching different items on and off for a link (in database entry). By default links are added as external=0. Changing to 1 makes sub - links always appear.
-
-
Superfish module
I use superfish module if i want drop down menus. It's very easy and flexible
Because this should be easy...
... and it's ridiculous that it isn't, here's the simple steps. This turns your menu into a menu tree with as many levels as you want (can be all of them). After this, you can add whatever CSS or JS you want to this to make them open or close or expand or dropdown or whatever on mouseover, click, etc.
This prints to the page the whole output for the whole menu tree structured like this (may have more/less classes depending on theme). It doesn't impose anything else, it just gives you the whole Drupal menu in the HTML output to do your own thing with:
am not sure if this is the
am not sure if this is the correct post for my question ! am quite new to drupal
i was wondering if there is a way to get the title of a parent menu item ?
i am rendering the submenu in a separated block of the main menu and i want to print the parent link title as a title for the submenu !
i hope u guys can point me in the right direction
thanx
Please try this instead,
Please try this instead,
Hope this helps.
Thank for saving my time
this simple code of your just worked superbly thank you very much i was just going here and there but finally found ha small and exact solution
using menu_tree_all_data and menu_tree_output
To render all menus from main menu define the following function in your theme's template.php file
function THEMENAME_preprocess_page(&$variables) {
// Get the entire main menu tree
$main_menu_tree = menu_tree_all_data('main-menu');
// Add the rendered output to the $main_menu_expanded variable
$variables['main_menu_expanded'] = menu_tree_output($main_menu_tree);
}
Then, in page.tpl.php, you can just use:
print render($main_menu_expanded);in template.php of the theme
in template.php of the theme you can add the following code
Thanks!