You are here

function nice_mega_dropdowns_get_dropdown in Nice Menus 7.2

Same name and namespace in other branches
  1. 7.3 nice_mega_dropdowns/nice_mega_dropdowns.module \nice_mega_dropdowns_get_dropdown()

This function is called by nice_menus module to get the dropdown content for a given menu item.

1 call to nice_mega_dropdowns_get_dropdown()
theme_nice_menus_build in ./nice_menus.module
Helper function that builds the nested lists of a Nice menu.

File

nice_mega_dropdowns/nice_mega_dropdowns.module, line 109
Module which allows nodes to be used as dropdown menus.

Code

function nice_mega_dropdowns_get_dropdown($menu_item) {
  $dropdowns = variable_get('nice_mega_dropdowns', array());
  $mlid = $menu_item['link']['mlid'];

  // Check if this menu item has a mega dropdown
  if (isset($dropdowns[$mlid])) {
    $cache = cache_get('nice_mega_dropdowns');

    // If this dropdown is cached, return it immediately
    if (isset($cache->data[$mlid])) {
      return $cache->data[$mlid];
    }
    else {
      $nid = $dropdowns[$mlid];
      $node = node_load($nid);
      if ($node->status == 1) {
        $body = field_view_field('node', $node, 'body');

        // Cache the dropdown before returning it
        $cache->data[$mlid] = $body[0]['#markup'];
        cache_set('nice_mega_dropdowns', $cache->data);
        return $body[0]['#markup'];
      }
    }
  }
  else {
    return FALSE;
  }
}