You are here

class og_CrumbsMultiPlugin_group_post in Crumbs, the Breadcrumbs suite 7.2

Same name in this branch
  1. 7.2 plugins/crumbs.og.inc \og_CrumbsMultiPlugin_group_post
  2. 7.2 plugins/crumbs.og.2.inc \og_CrumbsMultiPlugin_group_post
Same name and namespace in other branches
  1. 7 plugins/crumbs.og.inc \og_CrumbsMultiPlugin_group_post
  2. 7 plugins/crumbs.og.2.inc \og_CrumbsMultiPlugin_group_post

Use the group node as a parent for group posts. The priorities can be configured per group content type.

Hierarchy

Expanded class hierarchy of og_CrumbsMultiPlugin_group_post

File

plugins/crumbs.og.inc, line 24

View source
class og_CrumbsMultiPlugin_group_post implements crumbs_MultiPlugin {

  /**
   * {@inheritdoc}
   */
  function describe($api) {
    $types = node_type_get_types();
    foreach ($types as $type) {
      if (og_is_group_content_type('node', $type->type)) {
        $api
          ->addRule($type->type);
      }
    }
  }
  function findParent__node_x($path, $item) {
    if (FALSE === ($node = crumbs_Util::itemExtractEntity($item, 'node', 1))) {
      return NULL;
    }
    $items = field_get_items('node', $node, 'group_audience');
    if (is_array($items)) {
      foreach ($items as $item) {
        $row = db_query("SELECT * FROM {og} WHERE gid = :gid", array(
          ':gid' => $item['gid'],
        ))
          ->fetchObject();
        if ($row && $row->entity_type === 'node') {
          $parent_path = $this
            ->getParentPath($row->etid, $node);
          return array(
            $node->type => $parent_path,
          );
        }
      }
    }
    return NULL;
  }

  /**
   * This method can be overridden by custom plugins that inherit from this one,
   * e.g. to set a different parent for group events than for group discussions.
   *
   * @param int $group_nid
   * @param object $group_post
   *
   * @return string
   */
  protected function getParentPath($group_nid, $group_post) {
    return 'node/' . $group_nid;

    /*
     * Example:
     * switch ($group_post->type) {
     *   case 'event':
     *     return 'node/' . $group_nid . '/events';
     *   case 'discussion':
     *     return 'node/' . $group_nid . '/forum';
     *   default:
     *     return 'node/' . $group_nid;
     * }
     */
  }

}

Members

Namesort descending Modifiers Type Description Overrides
og_CrumbsMultiPlugin_group_post::describe function Overrides crumbs_MultiPlugin::describe
og_CrumbsMultiPlugin_group_post::findParent__node_x function
og_CrumbsMultiPlugin_group_post::getParentPath protected function This method can be overridden by custom plugins that inherit from this one, e.g. to set a different parent for group events than for group discussions.