You are here

function menu_block_get_title in Menu Block 7.2

Same name and namespace in other branches
  1. 6.2 menu_block.module \menu_block_get_title()
  2. 7.3 menu_block.module \menu_block_get_title()

Retrieves the menu item to use for the tree's title.

Parameters

bool $render_title_as_link: boolean A boolean that says whether to render the title as a link or a simple string.

Return value

array|string A render array or string containing the tree's title.

1 call to menu_block_get_title()
menu_tree_build in ./menu_block.module
Build a menu tree based on the provided configuration.

File

./menu_block.module, line 565
Provides configurable blocks of menu items.

Code

function menu_block_get_title($render_title_as_link = TRUE) {
  $menu_item = menu_block_set_title();
  if (is_string($menu_item)) {

    // The tree's title is a menu title, a normal string.
    $title = array(
      '#markup' => check_plain($menu_item),
    );
  }
  elseif ($render_title_as_link) {

    // The tree's title is a menu item with a link.
    if (!empty($menu_item['in_active_trail'])) {
      $menu_item['localized_options']['attributes']['class'][] = 'active-trail';
    }
    $title = array(
      '#type' => 'link',
      '#title' => $menu_item['title'],
      '#href' => $menu_item['href'],
      '#options' => $menu_item['localized_options'],
    );
  }
  else {
    $title = array(
      '#markup' => check_plain($menu_item['title']),
    );
  }
  return $title;
}