[development] How to add menu entry for certain node type?

Andrew Berry andrewberry at sentex.net
Tue Nov 3 00:40:08 UTC 2009

On 2009-11-02, at 12:25 AM, Zhang Xiao wrote:

> let's say node/456 is not a company node, then there is no tab  
> called "employees" in node 456's page.

Yes, you can do this without much code with CCK and Views. It's likely  
the best solution - if you're new to Drupal, please look at those  
before writing another custom module :). But, that doesn't answer the  
development question of adding a menu tab on nodes of a specific  
content type (which is what Views would do for you automatically).

What you want to do is set the 'access callback' and 'access  
arguments' in your hook_menu() implementation. If the node doesn't  
meet the conditions to show the menu tab, return FALSE. signup has a  
nicely documented example; take a look at signup's signup_menu() and  
_signup_menu_access() functions.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2672 bytes
Desc: not available
Url : http://lists.drupal.org/pipermail/development/attachments/20091102/38ce9a48/attachment.bin 

More information about the development mailing list