You are here

function og_views_view_group in Organic groups 6

Same name and namespace in other branches
  1. 6.2 modules/og_views/og_views.module \og_views_view_group()

Embed the configured group homepage.

1 call to og_views_view_group()
og_views_nodeapi in modules/og_views/og_views.module

File

modules/og_views/og_views.module, line 194

Code

function og_views_view_group($node, $teaser, $page) {
  if ($name = variable_get('og_home_page_view', 'og_ghp_ron')) {

    // There is a view defiened to act as the group's home page.
    $view = views_get_view($name);
    if (!$view) {
      drupal_set_message(t('The View %name was not found. Check your variables table or settings.php.', array(
        '%name' => $name,
      )), 'error');
    }
    else {
      $built = $view
        ->preview('default', array(
        $node->nid,
      ));
    }

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

      // If views hasn't show any text we show og's empty text.
      // Otherwise show it to everybody.
      og_home_empty($node);
    }
    drupal_set_title(filter_xss_admin($view->build_info['title']));
  }
  else {
    drupal_set_title(filter_xss_admin($node->title));
    drupal_add_feed(url("node/{$node->nid}/feed"), drupal_get_title());
  }
}