Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Order/sort activity by “most favorites”

@dankicity

Member

`<?php
$popular_activities = my_get_popular(); // returns an array of activity IDs
for ($i = 0; $i<count($popular_activities); $i++){

if (empty($popular_activities[$i])) continue;

$activity = new BP_Activity_Activity($popular_activities[$i]);

if (!$activity) continue; ?>

// your customized activity entry template

`

It’s a pretty ugly way of doing it but it got me started. Main defect, as I don’t yet get inserting activities into the activity template (without it doing it’s own query), is that I do one query to get the popular ids and then a query per activity (done in “BP_Activity_Activity”). Also, you’re bypassing all the the filters, pagination and other stuff in the activities_template, or I am. Since I’m just directly printing the values…

`
content; ?>
user_id ); ?>
user_id ); ?>
date_recorded ); ?>
$activity->user_id, ‘width’ => 20, ‘height’ => 20, ’email’ => $activity->user_email) ); ?>
`

You would need to do a query … [edit] nevermind ray gave that already

Skip to toolbar