New variable

Events happening in the community are now at Drupal community events on www.drupal.org.
reelay.bidyut's picture

Hi all, If I create a new menu and I want to show in a particular in my theme then what variable will I print,
like in the place primary links we write "$primary_links". Please help any one I am new in Drupal.

Comments

When you create a menu it

dale42's picture

When you create a menu it automatically creates a block for you in admin/build/block. You can assign the menu block to any region in your template.

If you do want to print it on your own using the same method as primary and secondary links, you need to grab the menu as an array using menu_navigation_links(). The print function you place in your theme's page.tpl.php would look something like:

<?php print theme('links', menu_navigation_links('name_of_menu'), array('class' => 'links my-links-class')); ?>

To be more elegant and closer to the way primary links work, you can follow the example of template_preprocess_page() and put something like this in your theme's template.php page preprocess function:

<?php $variables['my_menu_variable_name']  = menu_navigation_links('name_of_menu'); ?>

Then in your page.tpl.php:

<?php print theme('links', $my_menu_variable_name, array('class' => 'links my-links-class')); ?>

Warning, I haven't tested the code snippets.

New variable

reelay.bidyut's picture

Thank you this tips is quite helpful for me.

Vancouver

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: