Working With Drupal Primary Links
Ok I have to admit it my first CMS love was Wordpress. Still love the platform, but there are cases where it simply is not the best choice for the job at hand. In those cases, Cheeky Monkey Media turns to the all powerful Drupal.
Just to clear things up, I am the front end developer here, so that means that I write the themes. And let me tell you, writing a theme for Drupal and writing a theme for Wordpress are two different beasts altogether. The one thing about Wordpress is whenever I get stuck there are always loads of resources only a Google search away, Drupal..... not so much. I mean there are resources, just not as many.
So in an effort to help out the community I am going to write about the little quirks that really stand out to me as being significant
Primary link navigation
Navigation in Drupal is way different than the built in Wordpress navigation, although the new menus in WP 3.0 is getting closer. Anyways, when writing a theme for wordpress, I usually just write the standard list page function:
<?php wp_list_pages(); ?>
Then when I am ready to extend it I just add some attributes. You control levels of navigation by adding the depth attribute like this:
<?php wp_list_pages('depth=2'); ?>
this makes a two level navigation.
Drupal's navigation is much more grown up, as everything is handled by the CMS. You create menus and add content to the menu. To add the menu to the site, you have two choices, Blocks or Theme functions.
Ok, if you are still with me congrats, now normally to add the Primary links to a Drupal theme page you call something like this function
<?php print theme('links', $primary_links, array('class' =--> 'links primary-links')); ?>
Works great except.... you can only show the first level of navigation. Yes, you read that right one level of navigation. There is a whole bunch of geek talk about it here. But, here is the magic you want to remember.
Use this function instead:
$menu_name = variable_get('menu_primary_links_source', 'primary-links'); print menu_tree($menu_name);
You will find some more geek talk and explanation here.
Hope this helps :)