You are here

class TaxonomyDisplayBreadcrumbDisplayHandlerCore in Taxonomy display 7

Add a display handler to generate the same breadcrumb from Drupal core.

Hierarchy

Expanded class hierarchy of TaxonomyDisplayBreadcrumbDisplayHandlerCore

1 string reference to 'TaxonomyDisplayBreadcrumbDisplayHandlerCore'
taxonomy_display_update_7003 in ./taxonomy_display.install
Implements hook_update_N().

File

handlers/breadcrumb/core.inc, line 6

View source
class TaxonomyDisplayBreadcrumbDisplayHandlerCore extends TaxonomyDisplayBreadcrumbDisplayHandler {

  /**
   * Do not display anything to the user, we return an empty string.
   *
   * @see TaxonomyDisplayBreadcrumbDisplayHandler::buildBreacrumb()
   */
  public function buildBreadcrumb($term) {

    // Build breadcrumb like core does.
    // @see taxonomy_term_page()
    $current = (object) array(
      'tid' => $term->tid,
    );
    $breadcrumb = array();
    while ($parents = taxonomy_get_parents($current->tid)) {

      // Allow modules like i18n_taxonomy to alter the parents.
      drupal_alter('taxonomy_display_breadcrumb_parents', $parents);
      $current = array_shift($parents);
      $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
    }
    $breadcrumb[] = l(t('Home'), NULL);
    $breadcrumb = array_reverse($breadcrumb);
    drupal_set_breadcrumb($breadcrumb);
  }

  /**
   * Set a description when the user selects this option.
   *
   * @see TaxonomyDisplayHandlerForm::formFieldset()
   */
  public function formFieldset(&$form, &$values, $options = NULL) {
    $form['#description'] = t('The Drupal core breadcrumb will be used for the taxonomy terms.');
  }

  /**
   * Do not want anything stored, return void.
   *
   * @see TaxonomyDisplayHandlerForm::formSubmit()
   */
  public function formSubmit($form, &$values) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TaxonomyDisplayBreadcrumbDisplayHandlerCore::buildBreadcrumb public function Do not display anything to the user, we return an empty string. Overrides TaxonomyDisplayBreadcrumbDisplayHandler::buildBreadcrumb 1
TaxonomyDisplayBreadcrumbDisplayHandlerCore::formFieldset public function Set a description when the user selects this option. Overrides TaxonomyDisplayHandlerForm::formFieldset 1
TaxonomyDisplayBreadcrumbDisplayHandlerCore::formSubmit public function Do not want anything stored, return void. Overrides TaxonomyDisplayHandlerForm::formSubmit 1
TaxonomyDisplayHandlerForm::formValidate public function Perform validation on the custom formFieldset when the user submits. 1