Howdy,

I'm looking to do something fairly straight forward.

Say you have a menu with a few items in there, and in their configuration you wanted the url to be something like:

videos/5
podcasts/5
music/5
images/5

Now you can see where i'm going... i would like to have a wildcard in there, where the 5 is so that it will extract the node id and add that to make the menu nice and dynamic based on the node ;)

Can anyone help me on this bad boy?

Thanks in advance!

Jon....

Comments

nevets’s picture

To do what you want has a menu you need to code to handle the dynamic part. This first approach does not use a menu at all but instead uses a custom block. So create a custom block, make sure the input format is PHP and paste the following as the block body

<?php
if ( arg(0) == 'node' && is_numeric(arg(1))  && !arg(2) ) {
  $list = array();
  $nid = arg(1);

   $list[] = l('videos',  'videos/' . $nid);
   $list[] = l('podcasts',  'podcasts/' . $nid);
   $list[] = l('music',  'music/' . $nid);
   $list[] = l('iimages',  'images/' . $nid);

    print theme('item_list', $list);
}
?>

Then enable the block. This approach is simple and has the advantage the choices only show if viewing a node

You can also define a module that handles the paths 'videos', 'podcasts', 'music' and 'images' and using the same kind of test as above either handle the paths directly or call drupal_goto();

And if the paths represent views you might want to read http://drupal.org/node/70145