Hi All,
I've been at this for ages, I know there seems to be a lot out there about the pagination of DataObjects but for the life of me I can't figure out what I'm doing wrong!?!?
All the DataObjects show up on the page when only 6 should. Also the 1 2 | Next >> also shows up but has no effect.
ArticleItem.php is my DataObject
So in my ArticleHolder.php Controller I have:
class ArticlePage_Controller extends Page_Controller {
function ArticleItem() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1)
{
$_GET['start'] = 0;
}
$SQL_start = (int)$_GET['start'];
$newsEntries = DataObject::get('ArticleItems', '', 'Date DESC');
$doSet = new DataObjectSet();
foreach ($newsEntries as $newsEntry) {
if ($newsEntry->canView()) {
$doSet->push($newsEntry);
}
}
$doSet->setPageLimits($SQL_start, 10, $doSet->Count());
return $doSet;
}
}
And then in my ArticleHolder.ss I have:
<% control ArticleItems %>
<div class="article">
<h2>$ArticleTitle</h2>
<% if ArticleDesc %>
$ArticleDesc
<% end_if %>
<a href="$ArticleUrl.Link" target="_blank">Read More...</a>
</div>
<% end_control %>
<% if ArticleItems.MoreThanOnePage %>
<% if ArticleItems.PrevLink %>
<a href="$ArticleItems.PrevLink"><&;lt; Prev</a> |
<% end_if %>
<% control ArticleItems.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" title="Go to page $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<% if ArticleItems.NextLink %>
| <a href="$ArticleItems.NextLink">Next >></a>
<% end_if %>
<% end_if %>
All and any help is appreciated :)