function mmenu_page_build in Mobile sliding menu 7.2
Same name and namespace in other branches
- 7.3 mmenu.module \mmenu_page_build()
- 7 mmenu.module \mmenu_page_build()
Implements hook_page_build().
File
- ./
mmenu.module, line 889 - Primarily Drupal hooks and global API functions to manipulate mmenus.
Code
function mmenu_page_build(&$page) {
// Gets all mmenus markups and adds them to page.
$mmenus = mmenu_list();
$js_settings = array();
foreach ($mmenus as $mmenu) {
$name = $mmenu['name'];
// Checks if the mmenu was allowed to show.
if (mmenu_display_access($mmenu)) {
$mmenu['options']['classes'] = mmenu_get_all_classes($mmenu);
$page['page_bottom']['mmenu'][$name] = array(
'#theme' => 'mmenu',
'#mmenu' => $mmenu,
);
$js_settings[$name] = $mmenu;
}
}
// Outputs the mmenus settings as JSON, then we can do some custom
// stuffs in our own JS handlers.
if (count($js_settings) > 0) {
drupal_add_js(array(
'mmenu' => $js_settings,
), 'setting');
}
if (isset($page['page_bottom']['mmenu']) && count($page['page_bottom']['mmenu']) > 0) {
// Loads libraries.
$page['page_bottom']['mmenu']['#attached']['libraries_load'] = array(
'mmenu.hammer' => array(
'mmenu.hammer',
),
'mmenu.jquery.hammer' => array(
'mmenu.jquery.hammer',
),
'mmenu.main' => array(
'mmenu.main',
),
'mmenu.icomoon' => array(
'mmenu.icomoon',
),
);
}
}