You are here

class forum_CrumbsMonoPlugin_forumTerm in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 7.2 plugins/crumbs.forum.inc \forum_CrumbsMonoPlugin_forumTerm

Hierarchy

Expanded class hierarchy of forum_CrumbsMonoPlugin_forumTerm

File

plugins/crumbs.forum.inc, line 19

View source
class forum_CrumbsMonoPlugin_forumTerm implements crumbs_MonoPlugin {
  function describe($api) {
    return t('Let /forum/123 be the parent path of /forum/456, if 123 is the parent of 456.');
  }

  /**
   * Forums get their parent forums as breadcrumb parent.
   * The method name matches the router path "forum/%".
   * Forums are actually taxonomy terms, just the path is different.
   */
  function findParent__forum_x($path, $item) {
    $term = $item['map'][1];

    // Load the forum term,
    // if it hasn't been loaded due to a missing wildcard loader.
    // We could use forum_forum_load() instead, but this looks too scary
    // performance-wise, and we don't actually need it.
    // So we just use taxonomy_term_load() instead.
    $term = is_numeric($term) ? taxonomy_term_load($term) : $term;
    $parents = taxonomy_get_parents($term->tid);
    $result = array();
    foreach ($parents as $parent_tid => $parent_term) {
      if ($parent_term->vocabulary_machine_name == $term->vocabulary_machine_name) {

        // The parent forum
        return 'forum/' . $parent_tid;
      }
    }

    // Forum overview
    return 'forum';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
forum_CrumbsMonoPlugin_forumTerm::describe function Overrides crumbs_MonoPlugin::describe
forum_CrumbsMonoPlugin_forumTerm::findParent__forum_x function Forums get their parent forums as breadcrumb parent. The method name matches the router path "forum/%". Forums are actually taxonomy terms, just the path is different.