From 4278afa16bb46819975f95fe91021edcb852ca47 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sat, 17 Oct 2009 05:50:29 +0000 Subject: =?UTF-8?q?#473268=20by=20David=5FRothstein,=20sun,=20yoroy,=20G?= =?UTF-8?q?=C3=A1bor=20Hojtsy,=20cwgordon7,=20et=20al.:=20Allow=20contextu?= =?UTF-8?q?al=20editing=20of=20dang=20near=20everything=20on=20the=20page.?= =?UTF-8?q?=20Also=20adds=20a=20context=20system=20to=20menu=20local=20tas?= =?UTF-8?q?ks.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/menu/menu.api.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'modules/menu/menu.api.php') diff --git a/modules/menu/menu.api.php b/modules/menu/menu.api.php index 1339bf04d..65170333c 100644 --- a/modules/menu/menu.api.php +++ b/modules/menu/menu.api.php @@ -199,6 +199,21 @@ * this alone; the default alphabetical order is usually best. * - "menu_name": Optional. Set this to a custom menu if you don't want your * item to be placed in Navigation. + * - "context": (optional) Defines the type of a tab to control its placement + * depending on the requested context. By default, all tabs are only + * displayed as local tasks when being rendered in a page context. All tabs + * that should be accessible as contextual links in page region containers + * outside of the parent menu item's primary page context should be + * registered using one of the following contexts: + * - MENU_CONTEXT_PAGE: (default) The tab is displayed as local task for the + * page context only. + * - MENU_CONTEXT_INLINE: The tab is displayed as contextual link outside of + * the primary page context only. + * Contexts can be combined. For example, to display a tab both on a page + * and inline, a menu router item may specify: + * @code + * 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + * @endcode * - "tab_parent": For local task menu items, the path of the task's parent * item; defaults to the same path without the last component (e.g., the * default parent for 'admin/people/create' is 'admin/people'). @@ -496,6 +511,47 @@ function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) { ); } +/** + * Alter contextual links before they are rendered. + * + * This hook is invoked by menu_contextual_links(). The system-determined + * contextual links are passed in by reference. Additional links may be added + * or existing links can be altered. + * + * Each contextual link must at least contain: + * - title: The localized title of the link. + * - href: The system path to link to. + * - localized_options: An array of options to pass to url(). + * + * @param $links + * An associative array containing contextual links for the given $root_path, + * as described above. The array keys are used to build CSS class names for + * contextual links and must therefore be unique for each set of contextual + * links. + * @param $router_item + * The menu router item belonging to the $root_path being requested. + * @param $root_path + * The (parent) path that has been requested to build contextual links for. + * This is a normalized path, which means that an originally passed path of + * 'node/123' became 'node/%'. + * + * @see menu_contextual_links() + */ +function hook_menu_contextual_links_alter(&$links, $router_item, $root_path) { + // Add a link to all contextual links for nodes. + if ($root_path == 'node/%') { + $links['foo'] = array( + 'title' => t('Do fu'), + 'href' => 'foo/do', + 'localized_options' => array( + 'query' => array( + 'foo' => 'bar', + ), + ), + ); + } +} + /** * @} End of "addtogroup hooks". */ -- cgit v1.2.3