You are here

function og_preprocess_node in Organic groups 6.2

Same name and namespace in other branches
  1. 6 og.module \og_preprocess_node()

Preprocessor for Node template.

Enrich non-group nodes with the list of groups that the node belongs to.

File

./og.module, line 501
Code for the Organic Groups module.

Code

function og_preprocess_node(&$variables) {
  $og_links = array();
  $node = $variables['node'];

  // TODO: _both is not present during node preview and when you remove all audiences.
  // So group links don't curently show then.
  if (og_is_group_post_type($node->type) && !empty($node->og_groups_both)) {
    $current_groups = og_node_groups_distinguish($node->og_groups_both, FALSE);
    foreach ($current_groups['accessible'] as $gid => $item) {
      $og_links['og_' . $gid] = array(
        'title' => $item['title'],
        'href' => "node/{$gid}",
      );
    }
    $variables['og_links']['view'] = theme('links', $og_links);
    $variables['og_links']['raw'] = $og_links;
    array_unshift($variables['template_files'], 'node-og-group-post');
  }
  elseif (og_is_group_type($node->type)) {

    // This looks awful on a group node
    unset($variables['submitted']);
    array_unshift($variables['template_files'], 'node-og-group');
  }
}