I have a node type called XXXXX for example. When the node is displayed (by the author) usually there are two default tabs on the top:
View | Edit
Let's say I want to display some information related to the current node and I want to display that on a separate tab on the same level as View and Edit. So the tab line should look like this:
View | Edit | Related Information
The related information could be of any kind: static text, panels, blocks... ultimately I want to embed a view in this tab but the more general question is: How to add this tab for my node type XXXXX only?
Can you suggest some module(s) and settings, which allow for adding tabs without (with minimal) coding?
I know that Javascript Tools module provides tabs, also Panels module can be made to use those but all this is adding artificial visual tabs only. What I need is a real tab whit its own URL.
If a node's URL is http://mysite/node/111, much like the Edit tab loads in http://mysite/node/111/edit, I would like to add a new tab with an URL of type: http://mysite/node/111/new_tab
Thanks!
Comments
Any ideas?
Another drawback of the Panels 2 - Javascript Tools solution is that I get the tabs I want but the generic Drupal tabs (View and Edit) remain on top. It just doesn't look good to have two sets of tabs all related to the same node.
Any ideas, please?
Any ideas, please?
Lots of ideas... I see ;-)
Lots of ideas... I see ;-)
Anyone?
Anyone?
Tabs
I did something similar myself this week, and it took some hours to figure it out. Hopefully I have it roughly correct.
There's no non-coding way of doing this that I know of. I suggest making a new module (check drupal site for a starter module tutorial, if you haven't done one before. You'll just need the bare bones - a .module file and a .info file.)
I figured this out in part by adapting code from another module that uses tabs. By the way, could you let me know where you posted this in the forums, and I'll post this there too, see if people can't correct me where I'm going awry. This does work, but there may be an easier way, or problems with my interpretation of what Drupal is doing.
Three things to know before looking at the code:
Now, this is what I did. I wanted to add a 'help' tab to all profile account pages. I made a module and stuck in the following, (which I'd adapted from the subscriptions module - this also sticks a tab in people's profile. Always look for code to mimic!) (minus the php tags, which'll be in your module...)
The first part - admin/settings/useraccounthelp - just sets up an admin page for setting the URL the tab goes to. The settings function it calls is below, if you're interested. The key part is 'path' => "user/". arg(1) ."/".$helpurl. See here for what the arg function does. For your node problem, I guess you won't need to use the arg function coz you know what the node number is. I can't imagine you'll need to do the "if (arg" test either, though maybe you do - something like "if (arg(0) == 'taxonomy' && arg(2) == whatever your node type is.
It's "'type' => MENU_LOCAL_TASK" that makes the link a tab. Why not "'type' => TAB?" Christ only knows.
'callback' then tells it what function to call. I don't know if this is the quickest way of doing this, but my callback calls my send_to_help_page function, passing in the $helpurl. Then we get to the page I want via the drupalgoto function. Done.
Be interested to hear if that makes any sense and you can adapt it. Thought I'd better write since it took me so long to work out. I can't promise it's the best way of doing it, but it works for me. And don't forget to clear the cache!
Thanks, I replied with more
Thanks, I replied with more details in the Drupal Dojo thread.