How to add menu entry for certain node type?
Hi, For example I have 2 node types: 1. company 2. employee I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company. But i do not hope nodes in other types have this path, how to do that? thanks!
Look at: http://drupal.org/project/pathauto You can have automatic generated URL aliases dependent upon content type. Jamie Holly http://www.intoxination.net http://www.hollyit.net Zhang Xiao wrote:
Hi,
For example I have 2 node types: 1. company 2. employee
I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company.
But i do not hope nodes in other types have this path, how to do that?
thanks!
Jamie Holly wrote:
Look at:
http://drupal.org/project/pathauto
You can have automatic generated URL aliases dependent upon content type.
and, maybe more importantly, depending on your need, you can 'peek' inside and see how it's done :-)
On Sun, Nov 1, 2009 at 6:15 AM, Zhang Xiao <xellzhang@gmail.com> wrote:
For example I have 2 node types: 1. company 2. employee
I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company.
But i do not hope nodes in other types have this path, how to do that?
I don't think Pathauto or it's inner workings are the solution here. I think the solution is cck nodereference + views and a validator on the nid argument for "node type" is "company". Regards, Greg (i.e. maintainer of Pathauto). -- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal - http://www.masteringdrupal.com
hmm... thanks for the replies. but i think you did not get my idea... As in default theme Garland, if you go to a node page as an admin, you can see the tabs: view: node/123/view edit: node/123/edit so what i want is also a tab here: employees: node/123/employees (when and only when node 123 is a company node) let's say node/456 is not a company node, then there is no tab called "employees" in node 456's page. Does this make sense? Sorry for my bad English expression ;P On Nov 2, 2009, at 12:54 AM, Greg Knaddison wrote:
On Sun, Nov 1, 2009 at 6:15 AM, Zhang Xiao <xellzhang@gmail.com> wrote:
For example I have 2 node types: 1. company 2. employee
I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company.
But i do not hope nodes in other types have this path, how to do that?
I don't think Pathauto or it's inner workings are the solution here. I think the solution is cck nodereference + views and a validator on the nid argument for "node type" is "company".
Regards, Greg (i.e. maintainer of Pathauto).
-- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal - http://www.masteringdrupal.com
btw, I think I should use hook_link() for this case. But I am curious if menu system can do that? On Nov 2, 2009, at 1:25 PM, Zhang Xiao wrote:
hmm... thanks for the replies. but i think you did not get my idea...
As in default theme Garland, if you go to a node page as an admin, you can see the tabs: view: node/123/view edit: node/123/edit
so what i want is also a tab here: employees: node/123/employees (when and only when node 123 is a company node)
let's say node/456 is not a company node, then there is no tab called "employees" in node 456's page.
Does this make sense?
Sorry for my bad English expression ;P
On Nov 2, 2009, at 12:54 AM, Greg Knaddison wrote:
On Sun, Nov 1, 2009 at 6:15 AM, Zhang Xiao <xellzhang@gmail.com> wrote:
For example I have 2 node types: 1. company 2. employee
I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company.
But i do not hope nodes in other types have this path, how to do that?
I don't think Pathauto or it's inner workings are the solution here. I think the solution is cck nodereference + views and a validator on the nid argument for "node type" is "company".
Regards, Greg (i.e. maintainer of Pathauto).
-- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal - http://www.masteringdrupal.com
Views module can provide what you need. http://drupal.org/project/views The support mailing list or forums can help you with the details after you've read the available documentation. Good luck, Matt Zhang Xiao wrote:
hmm... thanks for the replies. but i think you did not get my idea...
As in default theme Garland, if you go to a node page as an admin, you can see the tabs: view: node/123/view edit: node/123/edit
so what i want is also a tab here: employees: node/123/employees (when and only when node 123 is a company node)
let's say node/456 is not a company node, then there is no tab called "employees" in node 456's page.
Does this make sense?
Sorry for my bad English expression ;P
On Nov 2, 2009, at 12:54 AM, Greg Knaddison wrote:
On Sun, Nov 1, 2009 at 6:15 AM, Zhang Xiao <xellzhang@gmail.com> wrote:
For example I have 2 node types: 1. company 2. employee
I hope for company node I have a path like "node/123/employees" which goes to the page display an employee list of this company.
But i do not hope nodes in other types have this path, how to do that?
I don't think Pathauto or it's inner workings are the solution here. I think the solution is cck nodereference + views and a validator on the nid argument for "node type" is "company".
Regards, Greg (i.e. maintainer of Pathauto).
-- Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com Mastering Drupal - http://www.masteringdrupal.com
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. --Andrew
oh... how stupid i am... totally forgot the access callback.... thanks you very much man! On Nov 3, 2009, at 8:40 AM, Andrew Berry wrote:
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.
--Andrew
participants (6)
-
Andrew Berry -
Greg Knaddison -
Jamie Holly -
Jeff Greenberg -
Matt Chapman -
Zhang Xiao