function navbar_pre_render in Navbar 7
Builds the Navbar as a structured array ready for drupal_render().
Since building the navbar takes some time, it is done just prior to rendering to ensure that it is built only if it will be displayed.
Parameters
array $element: A renderable array.
Return value
A renderable array.
See also
1 string reference to 'navbar_pre_render'
- navbar_element_info in ./
navbar.module - Implements hook_element_info().
File
- ./
navbar.module, line 264 - Administration navbar for quick access to top level administration items.
Code
function navbar_pre_render($element) {
// Define the breakpoints to switch from vertical to horizontal
// navbar presentation.
$breakpoints = array(
'narrow' => 'only screen and (min-width: 16.5em)',
'standard' => 'only screen and (min-width: 38.125em)',
'wide' => 'only screen and (min-width: 50em)',
);
// Allow for altering of the breakpoints.
drupal_alter('navbar_breakpoints', $breakpoints);
if (!empty($breakpoints)) {
$element['#attached']['js'][] = array(
'data' => array(
'navbar' => array(
'breakpoints' => $breakpoints,
),
),
'type' => 'setting',
);
}
// Get navbar items from all modules that implement hook_navbar().
$items = module_invoke_all('navbar');
// Allow for altering of hook_navbar().
drupal_alter('navbar', $items);
// Sort the children.
uasort($items, 'element_sort');
// Merge in the original navbar values.
$element = array_merge($element, $items);
// Render the children.
$element['#children'] = drupal_render_children($element);
return $element;
}