views:

21

answers:

2

Could anyone tell me how to create a dynamic link in drupal?

I want to create a link to a group membership list. I have created the view with the argument. How do I create the menu item link to the view? It will be different depending on the group.

Thanks

A: 

In short, you can't. Drupal's menu system caches the entire menu: menu items can't appear differently for different users (although you can set access permissions for them). If you want menu items to appear, you have to either register them in hook_menu() (which is only called when the menu is rebuilt), or you have to add them manually in Menu administration.

The handbook page on the Menu system provides more information about this.

However, you can create a fake menu using a block display in your view and the HTML list row style. This is useful if you wanted to have a category listing block, outside the main menu structure.

Mark Trapp
Thank you Mark for your answer. I like your idea about the fake menu and will look into that. I haven't got so much experience with programming drupal but may also have a go at using hook_menu - I will have to learn at some point!
Ben
A: 

It sounds like you may need to use views arguments to filter your results if you are pulling different "groups" based on a single view. I would start here to learn more about views arguments: http://drupal.org/node/54455, if this is indeed what you are trying to accomplish.

EDIT:

I guess it would help if I read the question fully. It sounds like you are already using arguments for your view. In this case you already have created dynamic links to your page. Try putting the arguments for each "group" at the end of the URL. For example if created a page display with a path news, you can pass the argument by appending it at the end of the URL. So, if you created an argument using "Node:Created Year" you could then filter this content by putting something like example.com/news/2009 to access only the nodes that were created in 2009. What you pass is dependent on the type of argument you have created.

bkildow
Thanks for your answer, I realised later I could put the argument at the end, however I wanted to look at using the same menu for all groups, so the menu path would need to automatically change depending on the group viewed. This would save the administrators having to create the menu item each time.
Ben