[support] Fwd: Adding Local Action Link

Steve Edwards killshot91 at gmail.com
Thu Feb 16 23:16:13 UTC 2012


For those of you eagerly awaiting the answer to this issue, there were two things I had to correct:

1) Since the link is on the node edit page, the parent URL needs to be node/%node (i.e. node/2), not node/%node/clone.  So in this case, I need to modify the menu item to be:

  $items['node/%node/clone_comment'] = array(
    'access callback' => 'clone_access_cloning',
    'access arguments' => array(1),
    'page callback' => 'monographs_node_check',
    'page arguments' => array(1, 2),
    'title' => 'Create For Comment version',
    'type' => MENU_LOCAL_ACTION,
  );

2) MENU_CONTEXT_INLINE has nothing to do with action_links.  In fact, when tabs and action links are being generated in the in menu_local_tasks() function, menu items with a context of MENU_CONTEXT_INLINE are specifically filtered out.

Once I fixed those, my action links showed up just fine.  

My preference would be to have the production and comment strings in their own part of the URL (i.e / node/2/clone/comment) so I don't have to parse a string, so if I anyone has a suggestion on how to do that, I'm all ears.

Thanks.

Steve

Begin forwarded message:

> From: Steve Edwards <killshot91 at gmail.com>
> Date: February 16, 2012 10:43:31 AM PST
> To: support at drupal.org
> Subject: Adding Local Action Link
> 
> I am building some functionality based on node_clone module that will allow me to clone certain node types and then implement hook_node_clone_alter() to modify some of the node content.  I would like to add a couple more links at the top of the page similar to the one node_clone already adds.  I've created my hook_menu implementations, cleared the cache, and rebuilt the menus, but the links are not getting added to the $action_links menu.
> 
> Here's my code:
> 
> /**
> * Implementation of hook_menu().
> */
> function monographs_menu() {
>  $items['node/%node/clone/comment'] = array(
>    'access callback' => 'clone_access_cloning',
>    'access arguments' => array(1),
>    'page callback' => 'monographs_node_check',
>    'page arguments' => array(1, 3),
>    'title' => 'Create For Comment version',
>    'weight' => 5,
>    'type' => MENU_LOCAL_ACTION,
>    'context' => MENU_CONTEXT_INLINE,
>  );
> 
>  $items['node/%node/clone/production'] = array(
>    'access callback' => 'clone_access_cloning',
>    'access arguments' => array(1),
>    'page callback' => 'monographs_node_check',
>    'page arguments' => array(1, 3),
>    'title' => 'Create production version',
>    'weight' => 5,
>    'type' => MENU_LOCAL_ACTION,
>    'context' => MENU_CONTEXT_INLINE,
>  );
> 
>  return $items;
> }
> 
> From what I've read and seen in other implementations, this is all I should need.  The menu item is created in the menu_router table (I can access it manually from the URL in a browser), and I've verified that the access callback is returning TRUE.  It's also getting to my custom callback (when the URL accessed manually), so I know that part is okay.  For some reason the links aren't being added to the $action_links variable in page.tpl.php.  Is there something else I'm missing?
> 
> Thanks.
> 
> Steve

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120216/f939ed8c/attachment.html 


More information about the support mailing list