I'm theming views-view--og.tpl.php, hoping to change the default group listing table into something a bit more attractive.

I'm looping through the $rows I have available, and for each of them I'm loading a $group_node object and creating a div with some specific content, such as the group's mission etc. I'd also want to present the lastest 2-3 group posts for each of the groups i'm fetching in $rows, along with their autoring and date information.

If it makes it any clearer, here's what i'm doing:

<?php if ($rows): ?>
    <?php if (drupal_get_path_alias(implode('/',arg())) == 'og') { ?>
        <div id="group-boxes">
        <?php foreach($variables['view']->result as $node) { ?>
            <?php $group_node = node_load($node->nid); ?>
            <!-- Some HTML using the $group_node data goes here -->
        <?php } ?>
    <?php } else { ?>
        <div class="view-content">
            <?php print $rows; ?>
    <?php } ?>
<?php elseif ($empty): ?>
<div class="view-empty">
  <?php print $empty; ?>
<?php endif; ?> 

How can I load all group posts related to a certain group node, and can this be done from the og home page (path /og), as I understand, it's considered outside of group context?

Help will be much appreciated,



I recommend creating a whole new view, which would list the three most recent posts for the group passed in the argument.

To make it work together with your existing og view, you'll want to attach the new view to your group content type using one of Viewfield, Views Field View and View reference modules.

For example, using Viewfield; to the group node type add a hidden View field called Recents. Set it to "Always use default value". Set the default value to the recent posts view. The argument is "%nid". Exclude its display from node teaser, full view etc.

In the group view, then, along with group name and mission, also add Attrview as a field. Good luck!


Using pagemanager makes this more easy. Use the default view 'og content' that comes when installing og and set format, fields, sorting etc as you like.

In pagemanager edit the page node_view and make sure there is a selectionrule 'This panel will be selected if Node being viewed is an OG group.'

Then you can use the og content views for displaying stuff and it works just like creating 'normal' views pages, with all benefits views gives.

Pagemanager is installed by ctools, which is necessary for og. You can create and use multiple (group)views on a group page this way.

This is afaik the default approach for displaying ogcontent. In CSS you can use the panel id selector to style specific to these pages.

adding views-stuff to a group page

  • Sorry didn't see it was such an old question (I am relatively new to this site)
    – Marcel
    Nov 26 '13 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.