aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/river2.php2
-rw-r--r--views/default/river/item/list.php29
2 files changed, 30 insertions, 1 deletions
diff --git a/engine/lib/river2.php b/engine/lib/river2.php
index d70f1e73b..d3d285aac 100644
--- a/engine/lib/river2.php
+++ b/engine/lib/river2.php
@@ -238,7 +238,7 @@
$offset = (int) get_input('offset',0);
// Get river items, if they exist
- if ($riveritems = get_river_items($subject_guid,$object_guid,$subject_relationship,$type,$subtype,$action_type,$limit,$offset,$posted_min,$posted_max)) {
+ if ($riveritems = get_river_items($subject_guid,$object_guid,$subject_relationship,$type,$subtype,$action_type,($limit + 1),$offset,$posted_min,$posted_max)) {
return elgg_view('river/item/list',array(
'limit' => $limit,
diff --git a/views/default/river/item/list.php b/views/default/river/item/list.php
index 781c18a48..8b7d37bd0 100644
--- a/views/default/river/item/list.php
+++ b/views/default/river/item/list.php
@@ -4,14 +4,43 @@
if (isset($vars['items']) && is_array($vars['items'])) {
+ $i = 0;
if (!empty($vars['items']))
foreach($vars['items'] as $item) {
echo elgg_view_river_item($item);
+ $i++;
+ if ($i >= $vars['limit']) break;
}
}
+
+ $baseurl = $_SERVER['REQUEST_URI'];
+ $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl);
+
+ $nav = '';
+
+ if ($vars['offset'] > 0) {
+ $newoffset = $vars['offset'] - $vars['limit'];
+ if ($newoffset < 0) $newoffset = 0;
+ $urladdition = 'offset='.$newoffset;
+ if (substr_count($baseurl,'?')) $prevurl=$baseurl . '&' . $urladdition; else $prevurl=$baseurl . '?' . $urladdition;
+
+ $nav .= '<a href="'.$prevurl.'">' . elgg_echo('previous') . '</a> ';
+ }
+
+ if (sizeof($vars['items']) > $vars['limit']) {
+ $newoffset = $vars['offset'] + $vars['limit'];
+ $urladdition = 'offset='.$newoffset;
+ if (substr_count($baseurl,'?')) $nexturl=$baseurl . '&' . $urladdition; else $nexturl=$baseurl . '?' . $urladdition;
+
+ $nav .= '<a href="'.$nexturl.'">' . elgg_echo('next') . '</a> ';
+ }
+
+ if (!empty($nav)) {
+ echo '<div class="river_pagination>"<p>'.$nav.'</p></div>';
+ }
?>
</div> \ No newline at end of file