Jump to:

3448 Posts in 1062 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Pagination not working - not displaying pages

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

Page: 1
Go to End
Author Topic: 678 Views
  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Pagination not working - not displaying pages Link to this post

    Hello, I am trying to use pagination with dataobjects, and it is not working properly.

    The function to get Dataobjects looks like this:

    function getLOTDs($pageLimit=5){

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

          $getLOTDs = DataObject::get('LOTD',"","Created DESC","","");

          $returnlotds = $getLOTDs->getRange($SQL_start, $pageLimit);

          return $returnlotds;
       }

    the template to display them looks like this:

    <% control getLOTDs %>   
          <li>
             <a href="$LOTD">$LName</a>
             </br>
             <% if Top.canDelLOTD %>
       <a href="LOTD/delLOTD/$ID">Brisanje</a>
             <% end_if %>
             <% if Top.canEditLOTD %>
                <a href="$EditLOTDForm">Izmijeni</a>
             <% end_if %>
             
             <% include LOTDPagination %>
             
          </li>
       <% end_control %>

    the LOTDPagination looks like this:

    <% if getLOTDs.MoreThanOnePage %>
       <div id="PageNumbers">
          <p>
             <% if getLOTDs.NotFirstPage %>
                <a class="prev" href="$getLOTDs.PrevLink" title="View the previous page">Prev</a>
             <% end_if %>
          
             <span>
              <% control getLOTDs.PaginationSummary(4) %>
                   <% if CurrentBool %>
                      $PageNum
                   <% else %>
                      <% if Link %>
                         <a href="$Link" title="View page number $PageNum">$PageNum</a>
                      <% else %>
                         &hellip;
                      <% end_if %>
                   <% end_if %>
                <% end_control %>
             </span>
          
             <% if getLOTDs.NotLastPage %>
                <a class="next" href="$getLOTDs.NextLink" title="View the next page">Next</a>
             <% end_if %>
          </p>
       </div>
    <% end_if %>

    Can't seem to find an error, the output I get from this is:

    Interni Carnet web
    Brisanje Izmijeni
    Monitor
    Brisanje Izmijeni
    YouTube
    Brisanje Izmijeni
    Index.hr
    Brisanje Izmijeni
    Net.hr
    Brisanje Izmijeni

    Default Admin
    Last visit: 24 May 2011

    Log Out

    So it displays only the 5 links properly, but it doesn't display the available pages and pagination bar where it should. Can som1 plz help?

  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Re: Pagination not working - not displaying pages Link to this post

    Solved!

    Martimiz helped me in another topic with this return from getLOTDs function

    return DataObject::get(
    $callerClass = 'LOTD',
    $filter = "",
    $sort = 'Created DESC',
    $join = '',
    $limit = "$SQL_start, $pageLimit"
    );

    678 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.