21493 Posts in 5784 Topics by 2622 members
General Questions
SilverStripe Forums » General Questions » Working Pagination sample for ArticlesHilder from tutorial
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 806 Views |
-
Working Pagination sample for ArticlesHilder from tutorial

12 April 2011 at 11:19pm
http://doc.silverstripe.org/private:recipes:pagination
Emptyhttp://doc.silverstripe.org/sapphire/en/reference/dataobjectset
Not completedTutorial for AtricleHolder
Can some one write "recommended" and right code?
-
Re: Working Pagination sample for ArticlesHilder from tutorial

12 April 2011 at 11:29pm Last edited: 12 April 2011 11:43pm
Edit:
http://doc.silverstripe.org/old/private:recipes:paginationfunction 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 %> -
Re: Working Pagination sample for ArticlesHilder from tutorial

13 April 2011 at 12:46am
Tnx Devlin.
I thought it would be more elegant:)
| 806 Views | ||
|
Page:
1
|
Go to Top |


