Howdy!
I'm trying to get pagination to work in the following situation. I am not nor do I want to use dataobjects.
So I have a StoryHolder Page that has 10 subpages (children). The subpages PageType is StoryPage.
The StoryHolder page has no submenu. The StoryPages are displayed in the main content area by $StoryTitle and $Content.Summary using
<% if Children %>
<% control Children %>
<div class="story">
<h3>$StoryTitle</h3>
$Content.Summary
</div>
<% end_control %>
<% end_if %>
But what I want to do is only have 3 stories display on the holder page with pagination for the other pages.
I've tried
StoryHolder.ss
<% if Children %>
<% control Children.Pagination %>
<div class="story">
<h3>$StoryTitle</h3>
$Content.Summary
</div>
<% end_control %>
<% end_if %>
<% if Story.MoreThanOnePage %>
<div class="pagination" style="float:right;">
<p>
<% if Story.NotFirstPage %>
<a class="prev" href="$Story.PrevLink" title="View the previous page">< Prev</a>
<% end_if %>
<span>
<% control Story.PaginationSummary(0) %>
<% if CurrentBool %>
<span class="current">$PageNum</span>
<% else %>
<% if Link %>
<a href="$Link" class="numbers" title="View page number $PageNum">$PageNum</a>
<% else %>
…
<% end_if %>
<% end_if %>
<% end_control %>
</span>
<% if Story.NotLastPage %>
<a class="next" href="$Story.NextLink" title="View the next page">Next ></a>
<% end_if %>
</p>
</div>
<% end_if %>
With
StoryHolder.php
function Story() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1)
{
$_GET['start'] = 0;
}
$SQL_start = (int)$_GET['start'];
$newsEntries = DataObject::get('StoryPage', '', 'Title DESC');
$doSet = new DataObjectSet();
foreach ($newsEntries as $newsEntry) {
if ($newsEntry->canView()) {
$doSet->push($newsEntry);
}
}
$doSet->setPageLimits($SQL_start, 5, $doSet->Count());
return $doSet;
I'm sure it's a little sloppy, I'm not the best coder and have been going through a lot of trial and error.
Anyway what it does now is show the pagination but instead of displaying only 3 on each &start=3 it shows all of them.
Something to do with the control Children maybe?
I've searched quite a bit for a solution but mostly all I can find is pagination for dataobjects which I don't want to use in this case.
Any help is appreciated :)