http://doc.silverstripe.org/private:recipes:pagination
Empty
http://doc.silverstripe.org/sapphire/en/reference/dataobjectset
Not completed
Tutorial for AtricleHolder
Can some one write "recommended" and right code?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
http://doc.silverstripe.org/private:recipes:pagination
Empty
http://doc.silverstripe.org/sapphire/en/reference/dataobjectset
Not completed
Tutorial for AtricleHolder
Can some one write "recommended" and right code?
Edit:
http://doc.silverstripe.org/old/private:recipes:pagination
function Articles($pagination=true) {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$Limit = $pagination==true ? (int)$_GET['start'].",5" : null;
$Articles = DataObject::get(
'Articles',
null,
'Date DESC',
null,
$Limit
);
return !empty($Articles) ? $Articles : false;
}
And in the template...
<% if Articles.MoreThanOnePage %>
<p style="text-align:center;">
<a href="$Articles.PrevLink" class="left"<% if Articles.PrevLink %><% else %> style="visibility:hidden;"<% end_if %>><< Previous</a>
<% control Articles.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" title="$PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<a href="$Articles.NextLink" class="right"<% if Articles.NextLink %><% else %> style="visibility:hidden;"<% end_if %>>Next >></a>
</p>
<% end_if %>
Tnx Devlin.
I thought it would be more elegant:)