Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Pagination for Multiple Page Types

Go to End

4 Posts   3280 Views


Community Member, 16 Posts

19 February 2009 at 5:15pm

Edited: 19/02/2009 5:19pm

Hi all,

I'm attempting to output some pagination for more than one page type. My function gets all the data as expected, but ".MoreThanOnePage" returns false. I followed the [url= in the wiki and it works for one page type, but not in this instance.

Here's what I have in my page controller:

function LatestNews($pageLimit=2) {

        if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;

        $SQL_start = (int)$_GET['start'];

        $articles = DataObject::get("Page", "`ClassName` IN ('DocPage', 'TechDocPage')");

        $returnarticles = $articles->getRange($SQL_start, $pageLimit);

         return $returnarticles;

And in my template I have the controller returning the page data as it should, but there is never any output for the pagination:

<% control LatestNews %>
    <p>$DateAdded.Format(j F Y)</p>
<% end_control %>
<% if LatestNews.MoreThanOnePage %>
    <% if LatestNews.PrevLink %>
       <a href="$LatestNews.PrevLink">&lt;&lt; Prev</a> |
    <% end_if %>

    <% control LatestNews.Pages %>
        <% if CurrentBool %>
        <% else %>
            <a href="$Link" title="Go to page $PageNum">$PageNum</a>
        <% end_if %>
    <% end_control %>

    <% if LatestNews.NextLink %>
        | <a href="$LatestNews.NextLink">Next &gt;&gt;</a>
    <% end_if %>
<% end_if %>

I must be missing something in my data object call?


Community Member, 15 Posts

27 April 2010 at 5:14am

I am having a similar problem - did you have any luck resolving?


Community Member, 253 Posts

27 April 2010 at 10:30am

If you follow the pagination recipe, it is fairly straight forward, the SQL_Limit needs to go in the DataObject::get(), rather than getRange once you pull all of the pages out.


Community Member, 15 Posts

27 April 2010 at 8:07pm

I was being a moron; hadn't updated my template page properly!! So I wasn't having a similar problem at all!