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.

Data Model Questions

Pagination not working - not displaying pages


Reply

2 Posts   692 Views

Avatar
Mackodlak

24 May 2011 at 9:20pm Community Member, 95 Posts

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?

Avatar
Mackodlak

25 May 2011 at 7:26pm Community Member, 95 Posts

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"
);