I am trying out the new view and edit tabs on the view and generally it seems to work OK, but I can't figure out how I could add a custom tab to the end of the tabs created by Views. Doing it the usual way in hook_menu() works fine at first and adds the tab at the right of the Views tabs, but as soon as I select my custom tab I get the Views tabs showing up as second level tabs below my tab, and their paths are broken.
As an example, I added this to hook_menu to create a setup tab:
$items[] = array(
'path' => $view->url .'/setup',
'title' => t('Setup'),
'description' => t('Calendar setup.'),
'access' => user_access('administer content'),
'callback' => 'drupal_get_form',
'callback arguments' => array('calendar_setup_form', $view),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
It looks just as it should in the initial display of my view and as long as I use any of the Views tabs. However, as soon as I click on my custom tab, the 'View' tab shows up as a second level menu tab below my 'Setup' tab, and the 'View' tab has a path of 'calendar/setup', instead of the right path of 'calendar'.
Maybe there's some Views function I should use instead of hook_menu(), and I see you have a few menu functions in there, but I can't quite figure out which one I should use to get the right results.
Or maybe I should just not be screwing around with your tabs :-)
Thanks, BTW, I think this is a really great feature.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views.module_29.patch | 2.23 KB | karens |
Comments
Comment #1
merlinofchaos commentedI had initially tried to make it so that views_ui_add_admin_tabs was actually a hook, and any module could add the tabs.
Then I realized that I couldn't tell if I was already looking at a tab or not, and the only solution I could think of was to look at the end of the URL and see if it is 'edit', 'clone', 'export' or 'view' and if it is, hey, we're looking at a tab.
Soooo if you add your own tab, you get hit by that code. I welcome suggestions for ways to deal with this cleanly, as I don't like the solution I have.
Comment #2
karens commentedWhat about something like this. I created a hook_views_tabs(), where modules can identify their tabs. I tested this in my own application with two custom tabs added by two different modules and it seems to work fine.
Comment #3
merlinofchaos commentedLooks like an acceptable solution, and better whan what I've got. Thanks!
Comment #4
(not verified) commentedComment #5
gemini commentedI actually got around without using the patch.
I looked up the views_ui_add_menu_items() and copied first 2 items from it into my custom function, so it now looks like this and works:
Basically it adds 2 tabs: View and Submit New Listing in my case. Works without any patches.
Comment #6
traceelements commentedThis is exactly what I'm trying to do. Please excuse my ignorance, but where do I go to copy it into a "custom function"? I see this earlier thread was for 5.x. Will this still apply to 6.x?
Comment #7
merlinofchaos commentedNothing in this issue is applicable to Views for D6. Resetting status.
Comment #8
anuradha parashar commentedHi,
i m working on assessment authoring soluction.In it i want to do some changes in quiz module like when we create new question of any question type that time whole details are shown in same page but now i want to show these details in two sprate tabs...like in 1st tab i can only create a question and 2nd tab i can do the configration of that perticular question.what i do for the same.
plese help me as soon as possible
Thanks in advance :-)
Comment #9
esmerel commented1) Please do not reopen old issues, especially ones that have been closed for 2 years. Open a new issue.
2) Do not change all of the data associated with an issue - that messes things up for other people, and it shows that your issue is completely unrelated to the previous issue, indicating that you need to open a new issue.
3) Support requests are never critical.
4) Needs work is for patches only.