Closed (fixed)
Project:
Activity
Version:
5.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 May 2008 at 20:38 UTC
Updated:
18 Nov 2008 at 12:12 UTC
I would like to display only the last 5 events logged by activity.module in the user profile pages, without the pager. I think the activity_table function should offer control over the display of the pager. Here is my solution:
function activity_table($activities, $showpager = 'TRUE') {
$display_headers = array(
'created' => array('field' => 'created', 'data' => t('Date')),
//t('Visible to'),
t('Message'),
);
$rows = array();
foreach ($activities as $activity) {
if ($activity['target_uid'] == ACTIVITY_ALL) {
$visible_to = t('Everyone');
}
else if ($activity['target_uid'] == $user->uid) {
$visible_to = t('You');
}
else {
// TODO: if this column gets reinstated load the user information differently
$visible_to = theme('username', user_load(array('uid' => $activity['target_uid'])));
}
if ($activity_message = activity_token_replace($activity)) {
$rows[] = array(
format_date($activity['created'], 'small'),
//$visible_to,
theme('activity', $activity_message, $activity),
);
}
}
$output = theme('table', $display_headers, $rows);
if ($showpager == TRUE) {
$output .= theme('pager');
}
return $output;
}
No other changes should be necessary as the pager will default to TRUE unless FALSE is specified.
In my user_profile.tpl.php I can now hide the pager like so:
$useractivity = activity_get_activity($account->uid, NULL, 5);
activity_table($useractivity, FALSE)
.
Comments
Comment #1
jaydub commentedThe new 5.4 branch and the new 6.x branch have an admin
setting for the number of activity records to show on activity
pages as you've requested. Note that you should not test this
out on a production site as many token patterns have changed
and no upgrade functions have been written at this point.
#314433: Activity 6.1 & 5.4
Comment #2
jaydub commentedComment #3
jaydub commentedConfigurable number of activity records is now part of 5.4 and 6.1 branches for activity page, activity blocks and for activity on user profiles.