You are here

function og_view_group in Organic groups 5

Same name and namespace in other branches
  1. 5.8 og.module \og_view_group()
  2. 5.2 og.module \og_view_group()
  3. 5.3 og.module \og_view_group()
  4. 5.7 og.module \og_view_group()
  5. 6.2 og.module \og_view_group()
  6. 6 og.module \og_view_group()
1 call to og_view_group()
og_nodeapi in ./og.module
Implementation of hook_nodeapi().

File

./og.module, line 1089

Code

function og_view_group(&$node, $teaser = FALSE, $page = FALSE) {
  if ($teaser || !$page) {
    $node->content['og_description'] = array(
      '#type' => 'item',
      '#title' => t('Description'),
      '#value' => $node->og_description,
    );
  }
  else {
    $bc[] = array(
      'path' => "og",
      'title' => t('Groups'),
    );
    $bc[] = array(
      'path' => "node/{$node->nid}",
      'title' => $node->title,
    );
    menu_set_location($bc);
    unset($node->content['body']);
    $node->content['og_mission'] = array(
      '#value' => check_markup($node->body, $node->format, FALSE),
      '#node' => $node,
      '#weight' => -3,
      '#theme' => 'og_mission',
    );
    $view = views_get_view(variable_get('og_home_page_view', 'og_ghp_ron'));
    $views_available = variable_get('views_defaults', array());
    if ($views_available[$view->name] == "disabled") {

      // Do nothing. Assume the group node type handles homepage, or theme layer - i.e. node-<node_type>.tpl.php
    }
    else {
      $view->url = 'node';
      $args[] = $node->nid;

      // TODO: use own callback for feeds
      if (arg(2) == 'feed') {
        $view->description = $node->og_description;
        $args[] = 'feed';
      }
      $built = views_build_view('embed', $view, $args, $view->use_pager, $view->nodes_per_page);

      // Views will set either total_rows or num_rows depending on whether View has a pager.
      if ($view->total_rows || $view->num_rows || $view->page_empty) {
        $node->content['view'] = array(
          '#value' => $built,
        );
      }
      elseif (empty($_POST)) {

        // Use this default empty text unless overridden by View (which is a usually not a good idea. This text is smart)
        og_home_empty($node);
      }
      drupal_set_title(check_plain(views_get_title($view, 'page')));
    }
  }
}