Theme an OG Home Page to break up Posted Nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
snorkers's picture

From someone still dealing with a few Drupal fundamentals, is there a way to either Theme or add blocks to an Organic Group home page, breaking apart the River of News in the style of the Drupal LA Group home page - without using Panels. Googling the web to bits, I really can't find a simple explanation anywhere on how to do this in Drupal 6. I'm assuming the LA page was done in D5 with OG Panels, but are there any clues on how to do this without Panels (it's a real memory gobbling module anyway and the OG Panels has been incompatible with D6 forever)..?

So there are 2 things I need help in:
1. Remove the River of News - Is it a case of tweaking the og_ghp_ron View (or setting OGs to use a different og_ghp_xxx View), or some theming cheekiness? (I couldn't see anything obvious in node-og.tpl.php, so is there some action needed template.php?)
2. Extract the various group post types using Views, to create separate blocks - so I could have one block for 'Recent news' and another block for 'Recent Wikis' etc. Still working my head round Views/Arguments (if that's where the solution lies), so would appreciate any clues to get going.

I'd be grateful if anyone could either point me in the direction of a relevant online resource, or if there was someone involved in creating the Drupal LA group site, that they could give me a few pointers... perhaps this could be a presentation at a forthcoming meeting too? I don't mind having a go at presenting it myself (pitched at a beginner/int level), as long as I can get my head around it first!

Comments

Create a view and give it a

christefano's picture

Create a new view and give it a name starting with "og_gpg" for it to show up in the list of OG home page presentations (in the the "group details" settings at admin/og/og). If you use Views arguments (or some custom code in the view's header or footer fields), each OG home page can look different depending on the URL or other variable.

Views arguments sound much scarier than they really are. There's a page of documentation about it that's pretty good at http://drupal.org/node/54455

Theming River of News on OG Home Page

snorkers's picture

Thanks Christefano - your reply got me looking in more appropriate places, although my head's hurting again about Arguments (get the concept, but still struggling with the Drupal implementation). Thought I'd post a solution - for the benefit of others - to part 1 of my original post:

How to remove (or adjust) the rendering of the River of News in the Group Home Page:
1. Go to Views > List and Edit the View used by Organic Groups (in my case og_ghp_ron).
2. At the bottom of the first column of the View control panel is an option for 'Theming', which describes all the theme template files available if you click on the hyperlink (see screen shot - attached).
3. Grab the default template code by clicking on the element you wish to adjust - in my case I want to change the way the posts are displayed on every Group Home Page, so select Display output - and copy to clip board.
4. Paste the default code into an editor of your choice and adjust the PHP/HTML as required.
5. Save the file in your sites/all/themes/<> folder. In my case the file name is views-view--og-ghp-ron.tpl.php - but this is given to you as an option as described at step 2.
6. In my case I don't want to display a default list of Group Posts at all, so my views-view--og-ghp-ron.tpl.php file contains merely:

<?php
// $Id:
?>


<!--Display nothing!!!-->

7. And don't forget to empty the cache before gasping in amazement at your new lightweight OG home page.
8. In my case this just leaves a Title and a Mission statement and a few other custom fields that describe the OG concerned.

There's probably also a theme function override from og_views.module [to go in template.php] - but that's for another day and someone who knows what they're doing...

In the meantime, I need now to find out how to create a block for each Content Type that can be placed on each OG home page, that will list that Group's most recently posted nodes (eg, a block to show Group's most recent News nodes, most recent Wiki nodes, etc).

Thanks + block for each Content Type

autopoietic's picture

Thanks for this - I was struggling a little with theming groups home page.

I am running Node Hierarchy in concert with OG, so each group node will have descendents which I can create block views for by type. This is suitable for my purposes.

Block for OG River of News

snorkers's picture

Seem to be answering myself... but I thought I'd report back just in case anyone else out there is struggling.

To create a block showing the OG content is surprisingly easy - I hadn't appreciated the Drupal tracks the current OG in your browser session, and that there is a handy filter in Views.

To create a block (and page that replaces the 'More' link you can stick in a block) I created my own new View in Site building > Views > Add, although you may find it easier to 'clone' the og_tracker view. I called my view og_news, as all I want to show is the group's news articles

In the Default view settings, you need to change the Filter to include: Node: Published, Node:Type News (or whatever the content type it is you want to display), and then Organic groups: OG: Posts in current group (this was the really simple bit I'd overlooked).

From this default view, we can set up the Page and Block views pretty easily (see Advanced Help http://views-help.doc.logrus.com/help/views/display for more info). However, to link the block and page view took me a little longer, as somehow you need to pass the Group ID.

In the block view I configured, I only wanted to show the 5 most recent News articles, just showing the Node title and posted date. (Set the Fields and Sort Criteria accordingly). Under the view Basic Settings > More link, we want to set to 'No' (and make sure Pager is set to 'No'). To replace the functionality of the 'More' link, we need to insert a little PHP into the footer of our block. Click on Basic Settings > Footer, then click on 'Override'. Insert the following PHP (and make sure you use PHP format for the input filter):

<?php
$currentGroup
= og_get_group_context();
$groupId = $currentGroup->nid;
$link = l('Read more...', 'news-by-group/'.$groupId);
print
$link;
?>

This will create a custom hyperlink with the text reading 'Read more...' and (if the Group ID was 104) the link generated would be news-by-group/104

The Group ID is effectively the input to an Argument we need to handle in a page view... so in our Page view, we need to set Page Settings > Path to news-by-group. We then need to create an Argument:
1. First click on the 'Argument' heading in the View control panel (center column, middle box) and click 'Override' - so that the argument is not applied to the other default/feed/block views
2. Add a new Argument (the + symbol) of type Organic groups: Groups
3. Set the title to be %1 News - the %1 being the argument parameter being passed (ie, the Group concerned)
4. Set 'Action to take if argument is not present' to Display all values
5. Update and Save View

So all we need to do is add our block to a Region in Site building > Blocks, and the 'Group news' block shows on every page that is either a Group node, or a node that has been posted to a Group (kinda). Clicking on the Read more... link takes to a page that shows us a more detailed listing of that Group's News nodes.

Daresay there are ways to improve it - haven't sussed a way to deal with it if no argument is passed (ie, site/news-by-group/ to show all Group news articles. I've also skipped over a lot of other Views functionality, as there are some good tutorials out there - great video materials on Views at http://drupal.org/node/248766 and http://gotdrupal.com/videos/drupal-block-system explains the block system pretty well.
Anyways... a week ago I ran away at Arguments, so this is progress - hope this helps someone else

Great!

ariyo132's picture

Thanks rgcarr,

I followed your instructions, and it works perfectly! While og_panels is not ready for Drupal 6, I can have work around using those steps, and combine them with custom themeing.

Once again, thanks a lot!

Great!

advseb's picture

Many thanks for those descriptions, they really helped a lot!

Sebastian

Works well - got a question though

project10's picture

It does what you say, but with mine at the top of the river of news page it says "no posts in this group" what did I do wrong?

The first thing that comes to my mind

mal@groups.drupal.org's picture

Is that you created content, but did not assign it to the particular group. When creating the content, there should be a set of checkboxes in the "audience" section of the page. You need to be sure the appropriate boxes are checked, thus assigning the content to the particular group.

Also, I noticed that the Group doesn't count the Homepage as content. It also does not count the group admin as a member of the group....I can't remember the exact details of how it works.

Ahaa. I see the problem too

mal@groups.drupal.org's picture

Its not because of group assignment, because I just assigned the group.

String Overrides

project10's picture

I chose to go with String Overrides to suppress that particular message, works fine, what a handy module that is!