Jump to:

22978 Posts in 11495 Topics by 2825 members

General Questions

SilverStripe Forums » General Questions » Pagination issue 2.4

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 145 Views
  • Judderman
    Avatar
    Community Member
    1 Post

    Pagination issue 2.4 Link to this post

    Hi

    I'm Editing one of my older 2.4 sites as the client has requested the jquery pagination needs to be a physical one which i added to the Category page yesterday, this was working initially but has since stopped giving me any results. I cant fault the code or find any reason why in the instance of the pagination function its no longer giving any results?

    The first function retrieves all the products to this category, this works but when i reference the function or replicate the process in pagination it doesn't return any results or errors?

    //Return the list of products for this category
       public function getProductsList(){
          return $this->Products(Null, 'Title ASC');
       }
       
       //Return the list of products using pagination
       function getChildPages() {
          if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
             $SQL_start = (int)$_GET['start'];
             $listedProducts = $this->getProductsList();
             $doSet = new DataObjectSet();
             foreach ($listedProducts as $listedProduct) {
                if ($listedProduct->canView()) {
                   $doSet->push($listedProduct);
                }
             }
          $doSet->setPageLimits($SQL_start, 12, $doSet->Count());
       return $doSet;
       }

    In the page we have:

    <div class="product_navigation">
    <% if getChildPages.MoreThanOnePage %><p><% if getChildPages.PrevLink %><a href="$getChildPages.PrevLink">&lt; Prev</a> | <% end_if %><% control getChildPages.Pages %><% if CurrentBool %><strong> $PageNum </strong><% else %><a href="$Link" title="Go to page $PageNum">$PageNum</a><% end_if %><% end_control %><% if getChildPages.NextLink %> | <a href="$getChildPages.NextLink">Next &gt;</a><% end_if %></p><% end_if %>
    </div>
    <div class="products">
       <% control getChildPages.Pagination %>
       <div class="box">
          <a href="$Link" title="$Title">
          <div class="img_holder">
          <% if MainImage %>
             $MainImage.CroppedImage(125,90)
        <% else %>
             <img src="$ThemeDir/images/comingsoon.jpg" alt="Image coming soon" />
          <% end_if %>
          </div>
          <h1>$Year $Make<br/>$Model</h1>
          <p>more information &raquo;</p>
          </a>
       </div>
    <% end_control %>
    </div>   

    Any help would be welcomed

    145 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.