home resources search newsjoinmembers: 6958
PHP Flash Java Ruby Windows Linux
drupal | Fri, 2008-05-23 05:20  tags: ,

I wanted to create a dynamic menu and store it in a variable like the default $primary_links or $secondary_links. This is so that the site administrator could update and create links for the footer without having to do HTML.

Step one was go login as the administrator and go to menus->add menu.

Create a new menu. Following the instructions under the textfield create a menu called "footer". Title the menu with "Footer links" so it is easy to find.

The system automatically adds a prefix to the menu name so the name in the database will be menu-footer.

Now that I have a menu and know its name I only had to find the right Drupal function and use the following code,

<?php
$footer_links 
theme('links',menu_navigation_links('menu-footer'),array('class' => 'links''id' => 'footlist'));
?>

The above code was okay but it uses the default formatting. I wanted to do something slightly different. This not the exact code but something to give you an idea of how to do things in a more custom fashion.


<?php $footer_links menu_navigation_links('menu-footer');?>
<div id="navigation">
<?php if (is_array($footer_links)) : ?>
<ul id="foot-list">
<?php foreach ($footer_links as $link): ?>
<li><?php print $link?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>

I added this to the bottom of page.tpl.php. I only had one last step and that was to start creating some links for the menu. I went to the menus area and saw a new link called "Footer links". Clicking on this brought a form for adding links and I could see the parent would be set as "<Footer links>". I added a few more links and I was done. The next thing I did was to add a page and use the menu settings in the form to add a link to the footer.

Happy publishing!

printer-friendly version

drupal's picture
Join Hiveminds and link to your website or blog.
Thoughtbox - So what did you think?



 
 
Web Developers Silverlight Content Management Systems Windows Adobe Flex Silverlight eRuby Adobe Flex
 videos
 articles
 blogs
 comments
 downloads
sitemap

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top