Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Dispalay pages...(paging)

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 2
Go to End
Author Topic: 2078 Views
  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Dispalay pages...(paging) Link to this post

    Hi, guys... it's possible make one template and show all pages in my html... i want paging items 5 in 5 but... first i have charge all pages in hmtl code... example:

    <div class="item">   /*first page
       <ul>      
                   <li><a href="13">ITEM 1 </a></li>
                   <li><a href="12">ITEM 2</a></li>
                   <li><a href="7">ITEM 3 </a></li>
                   <li><a href="6">ITEM 4 </a></li>
                   <li><a href="5">ITEM 5 </a></li>
       </ul>
    </div>

    <div class="item">   /*second page
       <ul>      
                   <li><a href="13">ITEM 6 </a></li>
                   <li><a href="12">ITEM 7</a></li>
                   <li><a href="7">ITEM 8 </a></li>

       </ul>
    </div>

    2 pages i have write in html whithout query:

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

    how i resolve this problem?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Dispalay pages...(paging) Link to this post

    Sorry I don't follow exactly - you are trying to add pagination no?

    I've looked for the doc page, but could find it.. how about this instead...

    http://www.silverstripe.org/general-questions/show/14780#post295050

  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Re: Dispalay pages...(paging) Link to this post

    hi!!
    thank's for the tip but not quite what I am seeking...
    I've a jquery that makes the pagination, but i have the query's divided for div's 5 in 5 items!
    well i'have first write code in html...

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Dispalay pages...(paging) Link to this post

    something like in your Page controller...

    function Results {
    $iPageLength = 5;

    $dos=DataObject::get('SomeObject');
    $dos->setPageLength($iPageLength);

    $dosResults= new DataObjectSet();
    for ($i=0;$i<$dos->TotalPages();$i++) {
    $dosResults->Items = new DataOBjectSet();
    $dosResults->Items = $dos->getRange($i*$iPageLength,$iPageLength);
    }
    returning $dos;
    }

    and this on your template...

    <% control Results %>
    <% control Items %>
    $ItemData
    <% end_control %>
    <% end_control %>

    If this doesn't make sense or has bugs (it is untested) then please read the documentation on templates and dataobjects (help - docs or api - and search)

  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Re: Dispalay pages...(paging) Link to this post

    function getResults() {
          
          $iPageLength = 5;
          
          $dos = DataObject::get('Problema',"`CategoriaProbID` = '{$this->ID}'");
          $dos->setPageLength($iPageLength);
          
          //echo TotalPages($dos);
          
          //$dos= new DataObjectSet();
          //echo $dos->pergunta;
          //echo $dos->count();
          
          //echo $dos->getRange();
          /*
          for ($i=0;$i<$dos->TotalPages();$i++) {
                $dosResults->Items = new DataOBjectSet();
                $dosResults->Items = $dos->getRange($i*$iPageLength,$iPageLength);
          }
          //echo $dos->getRange();
          */
          
          return $dos ? $dos : false;
          
          }

    Why have a error?

    whats difrence

    $dos=DataObject::get('SomeObject');
    $dos = DataObject::get('SomeObject',$filter);

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Dispalay pages...(paging) Link to this post

    always help if you actually provide the error message...

  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Re: Dispalay pages...(paging) Link to this post

    that's de error...

    HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts
    2078 Views
Page: 1 2
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.