You are here

class context_reaction_breadcrumb in Context 7.3

Same name and namespace in other branches
  1. 6.3 plugins/context_reaction_breadcrumb.inc \context_reaction_breadcrumb
  2. 6 plugins/context_reaction_breadcrumb.inc \context_reaction_breadcrumb

Set the breadcrumb using a context reaction.

Hierarchy

Expanded class hierarchy of context_reaction_breadcrumb

2 string references to 'context_reaction_breadcrumb'
_context_context_plugins in ./context.plugins.inc
Context plugins.
_context_context_registry in ./context.plugins.inc
Context registry.

File

plugins/context_reaction_breadcrumb.inc, line 6

View source
class context_reaction_breadcrumb extends context_reaction_menu {

  /**
   * Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path.
   */
  function set_active_trail_from_link($item) {
    $breadcrumb = array(
      l(t('Home'), '<front>'),
    );
    $result = db_select('menu_links')
      ->fields('menu_links', array(
      'p1',
      'p2',
      'p3',
      'p4',
      'p5',
      'p6',
      'p7',
      'p8',
    ))
      ->condition('hidden', 0)
      ->condition('link_path', $item['link_path'])
      ->execute();
    while ($parents = $result
      ->fetchAssoc()) {
      $set = FALSE;
      foreach (array_filter($parents) as $plid) {
        $parent = menu_link_load($plid);
        if ($parent && $parent['access'] && empty($parent['hidden']) && !empty($parent['title'])) {
          $set = TRUE;
          $breadcrumb[] = l($parent['title'], $parent['href']);
        }
      }

      // Only set the breadcrumb if one or more links were added to the
      // trail. If not, continue iterating through possible menu links.
      if ($set) {
        drupal_set_breadcrumb($breadcrumb);
        break;
      }
    }
  }

  /**
   * Return the title to be used for the current menu item.
   */
  function get_link_title($item) {
    return module_exists('i18n_menu') ? _i18n_menu_link_title($item) : $item['title'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_reaction::$description property
context_reaction::$plugin property
context_reaction::$title property
context_reaction::get_contexts function Retrieve active contexts that have values for this reaction.
context_reaction::settings_form function Settings form. Provide variable settings for your reaction. 2
context_reaction::__clone function Clone our references when we're being cloned.
context_reaction::__construct function Constructor. Do not override.
context_reaction_breadcrumb::get_link_title function Return the title to be used for the current menu item.
context_reaction_breadcrumb::set_active_trail_from_link function Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path. Overrides context_reaction_menu::set_active_trail_from_link
context_reaction_menu::execute function Provide active trail in all menus in which our path appears.
context_reaction_menu::fetch_from_context function Overrides parent function to include legacy handling for old format of just storing a single path. Overrides context_reaction::fetch_from_context
context_reaction_menu::get_active_paths function Helper function to return the list of currently active paths.
context_reaction_menu::options_form function Provide a form element that allow the admin to chose a menu item. Overrides context_reaction::options_form
context_reaction_menu::options_form_submit function Override of options_form_submit(). Trim any identifier padding for non-unique path menu items. Overrides context_reaction::options_form_submit