Adding a single-group activity stream to bp-social home page

Hi

I have a single group that I want to highlight on the home page by including its activity stream. I'm using 3-columns and would drop in a widget but I can't find a widget for it -- I'm already using the site-wide activity widget for example, but can't find one for a single group.

So it looks as if I will have to hard code it somehow.

Here's where I'm at. I have a copy of home.php in my child theme that I'm already making direct changes to.

Looking at the activity stream on the group page, I have identified that a template activity/activity-loop.php is used, which in turn calls activity/entry.php. I've made child copies of them and then I've dropped this which I lifted straight from the main activity.php template into the appropriate place in my home.php file:

<div class="activity single-group">
	<?php locate_template( array( 'activity/activity-loop.php' ), true ) ?>
</div><!-- .activity.single-group -->

and hey presto I have an activity stream sitting right where I want on my home page.

Except, it is the site-wide activity stream. I can't tell looking at it how to get it to do the same just for a single group.

Can anyone help me out?

Thanks!

  • DavidM
    • DEV MAN’s Mascot

    Hi terraling,

    I believe the file you'd want to be working in is entry.php which is called by activity-loop.php, both which reside in the theme's activity folder.

    At first glance it seems it might just require a conditional at the start of entry.php to see if the current item belongs to specified group. When I have a good moment, I'll see if I can get you this myself. I'm going to alert the developers to try and get you a quicker response here, though.

    Cheers,
    David

  • terraling
    • WPMU DEV Initiate

    Hi again David

    just giving it a little more thought, is putting a conditional there the right thing to do?

    I don't want it to display the activity stream *if* I'm looking at my specific group, what I want is when displaying the activity stream to kid it into thinking it is on the specific group page, so more like feeding it a parameter or hard-coding the group into a copy of entry.php no?

  • Richie_KS
    • HummingBird

    hi terraling
    you can achieve this by copy paste the attach activity-loop-group.php into bp-social/activity
    and call the locate_template() like this

    <div class="activity single-group">
    	<?php locate_template( array( 'activity/activity-loop-group.php' ), true ) ?>
    </div>

    remember to open the activity-loop-group and edit
    $query_string .= '&primary_id=1&per_page=10?';

    primary_id to your desired group id.
    pagination will not work in this features so you can per_page as much as you desired too.

    cheers

  • terraling
    • WPMU DEV Initiate

    Hi Richie

    thanks so much for getting back to me so quickly.

    I have dropped in your code, which works, sort of, but is not doing quite what I wanted.

    It appears to be displaying an activity stream of group activity only (ie ignores all other types of updates), BUT, what I need is for it to display the activity stream of ONE SPECIFIC GROUP.

    The file activity-loop-group.php has this function at the top:

    function my_custom_query_filter( $query_string ) {
    $query_string .= '&primary_id=1&per_page=10?';
    return $query_string;
    }

    I'm guessing &primary_id=1 is the bit that specifies that we want group activity, but how do I narrow it down to a single specific group?

    Thanks again for your help...

  • Richie_KS
    • HummingBird

    hi
    the primary_id would be the specific group id.

    try this for all activity

    function my_custom_query_filter( $query_string ) {
    $query_string .= '&primary_id=1&type=sitewide&per_page=10?';
    return $query_string;
    }

    also check for bp_has_activities() parameter in buddypress docs...

    haven't tested it yet..will test them out tomorrow morning...bit late here now..

    cheers

  • terraling
    • WPMU DEV Initiate

    Hi Richie

    changing the value of the primary_id is having no effect at all on what is displayed -- I'm still getting activity from ALL groups, irrespective of what number I set it to.

    Something IS happening in that if I change the per_page then that does work, so the function is being called correctly.

    Cheers

  • terraling
    • WPMU DEV Initiate

    OK, tinkering around, I think it was showing activity across ALL groups not just the group for which I'd specified the primary_id because the query omitted to say object=groups so that the primary_id wasn't necessarily being treated as a group id.

    Thanks for your help!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.