Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17480 Posts in 4474 Topics by 1973 members

Archive

SilverStripe Forums » Archive » Problem with pagination

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: Problem with pagination 986 Views
  • OzziNL
    avatar
    Community Member
    24 posts

    Problem with pagination Link to this post

    Hello, I am trying to solve a problem with pagination for two days now! I'll explain:

    //on a controller
       function showActivities() {
          
          isset($_GET['start']) ? $start = $_GET['start'] : $start = 0;
          
          $list = DataObject::get("ActiviteitPage", "","", "","{$start}," . AANTAL_ITEMS_ACTIVITEITENOVERZICHT );
             
          return ($list) ? $list : null;
       }

    On the template:

           <!-- pagination -->
              <% if showActivities.MoreThanOnePage %>
               <div id="head_itc_file">
               <% control showActivities.Pages %>
                  <% if CurrentBool %>
                     <img src="/themes/inventheon/images/file_itc.gif" alt="" />
                  <% else %>
                     <a href="$Link"><img src="/themes/inventheon/images/file_off_itc.gif" alt="" /></a>
                  <% end_if %>
               <% end_control %>
               </div>
              <% end_if %>
           <!-- end pagination -->
    //...cut
    $ActiviteitenLijst.Count //PRINTS 3
    <% include ActiviteitenLijst %> //PRINTS 3 ITEMS

    Now the problem: The pagination returns pages for 107 items. Whatever the numer of items per page, it is based on 107 item (1 -> 107 pages, 10 -> 11 pages )

    looking in the code I see the problem comes from:

    $this->setPageLimits($start, $length, $query->unlimitedRowCount());


    The last parameter is 107 and should be 5 (there are 5 ActiviteitPage items)

    Now: it gets odd:

    in this code in SQLQuery.php:

       function unlimitedRowCount( $column = "*" ) {
          $clone = clone $this;
          $clone->select = array("count($column)");
          $clone->limit = null;
          $clone->orderby = null;
          $clone->groupby = null;
          Debug::show($clone); // THIS DUMP LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!
          $queryContent = singleton('SiteTree')->extendedSQL();
          return $queryContent->execute()->value();
       }


    The dump line prints:

    SQLQuery::__set_state(array( 'select' => array ( 0 => 'count(*)', ), 'from' => array ( 'SiteTree' => '`SiteTree_Live`', 'InventheonPage' => 'LEFT JOIN `InventheonPage_Live` ON `InventheonPage_Live`.ID = `SiteTree_Live`.ID', 'ActiviteitPage' => 'LEFT JOIN `ActiviteitPage_Live` ON `ActiviteitPage_Live`.ID = `SiteTree_Live`.ID', ), 'where' => array ( 0 => '`SiteTree_Live`.ClassName IN (\'ActiviteitPage\')', ), 'orderby' => NULL, 'groupby' => NULL, 'having' => NULL, 'limit' => NULL, 'distinct' => NULL, 'delete' => NULL, 'extension_instances' => array ( ), 'class' => 'SQLQuery', ))


    I translate it myself to sql and that is:

    SELECT count(*)
    FROM SiteTree_Live
    LEFT JOIN `InventheonPage_Live` ON `InventheonPage_Live`.ID = `SiteTree_Live`.ID
    LEFT JOIN `ActiviteitPage_Live` ON `ActiviteitPage_Live`.ID = `SiteTree_Live`.ID
    WHERE `SiteTree_Live`.ClassName IN ('ActiviteitPage')


    And when I run it: 5 !!!!!!

    But the function SQLQuery::unlimitedRowCount() returns 107

    Please any help!!!
    I don't understand this anymore...

    Thanks,
    Oscar

  • OzziNL
    avatar
    Community Member
    24 posts

    Re: Problem with pagination Link to this post

    Case closed!
    Don't know how this code became as pasted but this function is not like the function in the Stable.

    986 Views
Page: 1
Go to Top

Currently Online: _Vince

Welcome to our latest member: AlfonsoGrondo

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

Comments on this website? Please give feedback.