Out of the box, the Drupal Organic Groups module doesn’t put the group name at the top of each group post. This looked a bit odd to use because we use a modified og_tracker block on our homepage to show registered users new group, blog and comment content.
When you clicked on the title of the group post from this block you didn’t really have a context in terms of which group you were in (apart from the not so conspicuous group tools block in the right sidebar.
A quick template override was needed. Here’s what I did:
- first I copied node.tpl.php to node-og-group-post.tpl.php in our sites/all/themes/custom/begrand960 directory (the actual directory will depend on your sites default template, ours is called begrand960)
- edited node-og-group-post.tpl.php and added the following code (just after <?php print $picture ?>)…
if ($node->og_groups && $page) {
$currentGroup = og_get_group_context();
print "
<h2><a href="/".$currentGroup->path."">";
print $currentGroup->og_description."</a></h2>
";
}
The og_get_group_context() function returns an array with lot’s of useful information. As always, you can dump the contents of an array in php by using:
print "
<pre>";
print_r($arrayName);
print "</pre>
";
Don’t forget to make sure you put the code inside existing php tags!
Hey presto! Nicely formatted link back to the parent group that only displays on the post page and not the group summary. Which is nice.
{ 1 comment… read it below or add one }
Error in my original post.
$currentGroup->og_description
should be
$currentGroup->title
Doh!