diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-13 16:15:42 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-13 16:15:42 +0000 |
commit | d24169856137d5327f657cd18ff50ea4190ab0a2 (patch) | |
tree | f42830d5e8789a5a9492b48db52feb8502b2f07b /views/default/river | |
parent | 2e41019e9e9942ab2aa580ef661864452e04ca6f (diff) | |
download | elgg-d24169856137d5327f657cd18ff50ea4190ab0a2.tar.gz elgg-d24169856137d5327f657cd18ff50ea4190ab0a2.tar.bz2 |
Simple river pagination.
git-svn-id: https://code.elgg.org/elgg/trunk@2748 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/river')
-rw-r--r-- | views/default/river/item/list.php | 29 |
1 files changed, 29 insertions, 0 deletions
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 |