function contextual_pre_render_links
contextual_pre_render_links($element)
Build a renderable array for contextual links.
Parameters
$element: A renderable array containing a #contextual_links property, which is a keyed array. Each key is the name of the implementing module, and each value is an array that forms the function arguments for menu_contextual_links(). For example:
array('#contextual_links' => array( 'block' => array('admin/structure/block/manage', array('system', 'navigation')), 'menu' => array('admin/structure/menu/manage', array('navigation')), ))
Return value
A renderable array representing contextual links.
See also
File
- modules/contextual/contextual.module, line 137
- Adds contextual links to perform actions related to elements on a page.
Code
function contextual_pre_render_links($element) { // Retrieve contextual menu links. $items = array(); foreach ($element['#contextual_links'] as $module => $args) { $items += menu_contextual_links($module, $args[0], $args[1]); } // Transform contextual links into parameters suitable for theme_link(). $links = array(); foreach ($items as $class => $item) { $class = drupal_html_class($class); $links[$class] = array( 'title' => $item['title'], 'href' => $item['href'], ); // @todo theme_links() should *really* use the same parameters as l(). $item['localized_options'] += array('query' => array()); $item['localized_options']['query'] += drupal_get_destination(); $links[$class] += $item['localized_options']; } $element['#links'] = $links; // Allow modules to alter the renderable contextual links element. drupal_alter('contextual_links_view', $element, $items); // If there are no links, tell drupal_render() to abort rendering. if (empty($element['#links'])) { $element['#printed'] = TRUE; } return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!contextual!contextual.module/function/contextual_pre_render_links/7.x