Problem/Motivation

We want to re-use a local context menu from a referencing node on it referenced node.

Setup:
Node1 references Node2 and Node3
We have custom subpages on Node1, like node/%node/pages, node/%node/employees etc.
Examples

  1. On Node2 & Node3, we want to show these same links which contextually belongs to Node1.
  2. We want to show links to the local tasks on the teaser view of a node.

Proposed resolution

Make it possible to pass a $router_item to the menu_local_tasks, making it possible to get local menus for a specific nodes when not on that nodes content page.

Remaining tasks

All aspects should be covered in the patch.

User interface changes

None.

API changes

None. (I do not consider adding a new optional parameter to a function for an API change, but please correct me if I am wrong)

Data model changes

None.

Comments

lslinnet created an issue. See original summary.

lslinnet’s picture

Assigned: lslinnet » Unassigned
Status: Active » Needs review
StatusFileSize
new1.81 KB

Added patch.

Unsure if there should be tests added for this and a little unsure how to write those to correctly test this change.

eliosh’s picture

I need this to show a user local task regardless of current path.

Thanks a lot !

eliosh’s picture

Regarding API change, we can think to create a "subfunction", something like this:

function menu_local_tasks($level = 0) {
  $router_item = menu_get_item();
  return _menu_local_tasks($level, $router_item)
}

function _menu_local_tasks($level, $router_item) {
 ...
}

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.