Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How can I filter The Activity Stream Loop with more than one scope (6 posts)

Started 4 months, 1 week ago by: _dorsvenabili

  • Profile picture of _dorsvenabili _dorsvenabili said 4 months, 1 week ago:

    Hi!!!

    I would like to show in the same activity tab the personal activity and the favourite activity. For that, I have modified the template activity-loop.php and I have change this line:

    if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) :

    for this one:

    if ( bp_has_activities( 'scope=friends,favorites' ) ) :

    As I found here: http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/

    But it doesn’t work, beacuse, I think that the parameter scope don’t accept more than one value. So, is there another way to show all the activity of friends and favourites in the same tab?

    Thanks so much!!! :)

  • Profile picture of abyss abysshorror said 4 months, 1 week ago:

    Hey ! try this:

    if ( bp_has_activities( 'scope=friends' ) || bp_has_activities( 'scope=favorites' )) :

  • Profile picture of _dorsvenabili _dorsvenabili said 4 months ago:

    Hi abysshorror!

    Thanks for reply so fast :) . I have tried your code and it doesn’t work, even I tried with && instead || but nothing. The problem is that using both ways, it only shows the first scope activitys, for example, using this:

    if ( bp_has_activities( 'scope=friends' ) || bp_has_activities( 'scope=favorites' )) :

    it only shows the friends activity. And there is another problem, if I use the code above, when I click on the load more link, it works, but showing the sames activities again and again.

    Somebody knows how can I solve this? Thanks! :)

  • Profile picture of Paul Gibbs Paul Gibbs said 4 months ago:

    bp_has_activities() queries the database, so the second call would overwrite the data from the first, not add to it. The scope argument only accepts a single parameter; I think you’d have to build your own version of bp_has_activities() and see if it will work.

  • Profile picture of abyss abysshorror said 4 months ago:

    @paulgibbs wouldn’t this work ?

    <?php while ( bp_activities() ) : bp_the_activity(); ?>
    		<?php if ( bp_get_activity_type() == 'activity_update' || bp_get_activity_type() == 'activity_comment' ) : ?>
    			<?php locate_template( array( 'activity/entry.php' ), true, false ); ?>
    		<?php endif; ?>
    	<?php endwhile; ?>
  • Profile picture of _dorsvenabili _dorsvenabili said 4 months ago:

    Yes @abysshorror it works, thanks, but it’s not what I was looking for.

    @DJPaul yes, I agree, the function that I have to modify is bp_activity_get() in bp-activity-functions.php to retrieve an activity or activities of both scopes :)