Add og group name and author to node

Last modified: August 23, 2009 - 19:19

This is to include the name of the author of a node and the group the node belongs to. From christefano's post at Drupal Groups: http://groups.drupal.org/node/15751.

Add the following code to the node type template in your theme folder.

<?php if ($submitted): ?>
  <?php if ($og_groups): ?>
  <!-- the post is submitted to a group -->
    <?php
      $og_projects
= array();
      foreach (
$node->og_groups_both as $key => $name) {
       
$og_projects[] = l($name,'node/'.$key,array('class'=>'group'));
      }
     
$og_projects = implode(', ',$og_projects);
   
?>
         
    <span class="submitted">
      <?php print $submitted ?>
      <?php print $og_projects; ?>
    </span>
    <?php elseif (!$og_groups): ?>
    <!-- the post is not submitted to a group -->
    <span class="submitted">
      <?php print $submitted ?>
    </span>
  <?php endif; ?>
<?php endif; ?>

The output will look like this:

Submitted by lsabug on November 20, 2008 - 3:29pm. For Testing Classroom blog

 
 

Drupal is a registered trademark of Dries Buytaert.