You are here

function ctools_menu_add_tab in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/menu.inc \ctools_menu_add_tab()

Dynamically add a tab to the current path.

This function allows you to dynamically add tabs to the current path. There are several important considerations to this:

  • First, Drupal doesn't really allow this. CTools lets this happen by overriding the theme function that displays the tabs. That means that custom themes which do not use CTools functions will not get the new tabs. You can provide instructions to your users about how to deal with this, but you should be prepared for some users not getting the new tabs and not knowing why.
  • Second, if there is only 1 tab, Drupal will not show it. Therefore, if you are only adding one tab, you should find a way to make sure there is already tab, or instead add 2.
  • Third, the caller is responsible for providing access control to these links.

Parameters

$link: An array describing this link. It must contain:

  • 'title': The printed title of the link.
  • 'href': The path of the link. This is an argument to l() so it has all of those features and limitations.
  • 'options': Any options that go to l, including query, fragment and html options necessary.
  • 'weight': The weight to use in ordering the tabs.
  • 'type': Optional. If set to MENU_DEFAULT_LOCAL_TASK this can be used to add a fake 'default' local task, which is useful if you have to add tabs to a page that has noen.
4 calls to ctools_menu_add_tab()
ctools_context_handler_pre_render in includes/context-task-handler.inc
Called to execute actions that should happen before a handler is rendered.
page_manager_page_execute in page_manager/plugins/tasks/page.inc
Execute a page task.
page_manager_term_view in page_manager/plugins/tasks/term_view.inc
Entry point for our overridden term view.
_ctools_menu_add_dynamic_items in includes/menu.inc

File

includes/menu.inc, line 42
General menu helper functions.

Code

function ctools_menu_add_tab($link = NULL) {
  static $links = array();
  if (isset($link)) {
    $links[$link['href']] = $link;
  }
  return $links;
}