You are here

function mmenu_page_bottom in Mobile sliding menu 8

Implements hook_page_bottom().

File

./mmenu.module, line 625
Primarily Drupal hooks and global API functions to manipulate mmenus.

Code

function mmenu_page_bottom(array &$page_bottom) {

  // 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)) {
      $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) {
    $page_bottom['#attached']['drupalSettings']['mmenu'] = $js_settings;
  }
  if (isset($page_bottom['mmenu']) && count($page_bottom['mmenu']) > 0) {

    // Loads libraries.
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.hammer';
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.jquery.hammer';
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.main';
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.icomoon';
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.basic_theme';
    $page_bottom['#attached']['library'][] = 'mmenu/mmenu.fresh_theme';
  }
}