Closed (fixed)
Project:
Media Gallery
Version:
7.x-1.0-beta3
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2011 at 15:24 UTC
Updated:
20 May 2012 at 11:20 UTC
Hello,
In order to create an "Add Gallery" action-link on the Galleries page I have implemented hook_menu_local_tasks like this:
<?php
function mymodule__menu_local_tasks_alter(&$data, $router_item, $root_path) {
if ($root_path == 'taxonomy/term/%') {
$item = menu_get_item('node/add/media-gallery');
$item['title'] = t('Add gallery');
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
?>
As you can see on the attached screenshot, the link appears twice on the page.
Can someone please tell me what I'm doing wrong?
| Comment | File | Size | Author |
|---|---|---|---|
| add-gallery.jpg | 13.67 KB | rombapa |
Comments
Comment #1
rombapa commentedAnswering my own question: it seems that the implementation of hook_menu_local_tasks_alter is called twice: first for the tabs and second for the actions. So Before adding the action link, I test whether $data['actions']['output'] is empty:
All suggestions/remarks are very welcome :-)
Comment #2
rombapa commentedCorrecting my own answer :)...
A 3rd condition is needed so that the Add Gallery link doesn't display for anonymous users
Comment #3
lsolesen commentedMarking this as fixed, as it seems you answered your own answer?