views:

15

answers:

0

What I want

I have several OG groups in which content can be published. I would like to display which OG groups a node has been published for when viewing the node page. Like in "This page is published for: Department A, Department B."

The code snipped below shows the data I have in the $node object in node.tpl.php. This data is generated by the OG module.

Extracted data from $node

    ...
    [og_groups] => Array (
      [993] => 993
      [2078] => 2078
    )
    [og_groups_both] => Array (
      [993] => Department A
      [2078] => Department B
    )
    ...

I know I could loop through the og_groups_both array in node.tpl.php and generate the output from there, but it feels like a quite dirty solution. The ideal solution would be to have a $og_groups variable in node.tpl.php, similiar to how $submitted is used in node.tpl.php (see below).

Example of how $submitted is used

   <?php if ($submitted): ?>
     <div class="submitted"><?php print $submitted; ?></div>
   <?php endif; ?>

Should I use hook_load() in a custom module to insert the new variable $og_groups in $node or use template_preprocess_node(&$variables)? What options do I have and which solution would you recommend?