You are here

function menu_item_container_preprocess_page in Menu item container 7

Same name and namespace in other branches
  1. 6 menu_item_container.module \menu_item_container_preprocess_page()

Alter the theme's primary and secondary links.

Most themes style the <a> tags in their links. We provide a wrapping link which uses only an empty anchor (#) so as to not break those themes. In actuality, a container is pretty useless in a non-hierarchal link list.

File

./menu_item_container.module, line 130
Provides containers for menu items.

Code

function menu_item_container_preprocess_page(&$variables) {
  foreach (array(
    'primary_links',
    'secondary_links',
  ) as $menu) {
    foreach (array_keys($variables[$menu]) as $key) {
      list($module, $id, ) = explode('/', $variables[$menu][$key]['href'] . '//', 3);
      if ($module == 'menu-item-container') {

        // Set the link title to be the themed container.
        $hooks = array(
          'menu_item_container__' . $id,
          'menu_item_container__' . str_replace('-', '_', $menu),
          'menu_item_container',
        );
        $variables[$menu][$key]['title'] = theme($hooks, array(
          'title' => '<a href="#">' . check_plain($variables[$menu][$key]['title']) . '</a>',
          'localized_options' => array(
            'html' => TRUE,
          ),
        ));
        $variables[$menu][$key]['html'] = TRUE;

        // Remove link path so theme_links() will wrap item with a span.
        unset($variables[$menu][$key]['href']);
      }
    }
  }
}