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:

1148 Posts in 322 Topics by 272 members

Data Model Questions

SilverStripe Forums » Data Model Questions » how to make Pagination on my PageHolder

Page: 1
Go to End
Author Topic: how to make Pagination on my PageHolder 1049 Views
  • fiord
    avatar
    Community Member
    50 posts

    how to make Pagination on my PageHolder Link to this post

    I want to do something similar to http://silverstripe.org/modules?start=10
    can share the code how to do Pagination with "Previous page" and "Next page" links

  • aram
    avatar
    Community Member
    481 posts

    Re: how to make Pagination on my PageHolder Link to this post

    Hi Fiord, you need to do something like this:

    mysite/code/Page.php

    //functions in Page_controller, gets a list of objects and paginates them
    function getObjects() {
    if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
    $SQL_start = (int)$_GET['start'];
    $doSet = DataObject::get(
    $callerClass = "$PageClass", // enter the Object type (e.g. 'MyPageType')
    $filter = "`ParentID` = '".$this->ID."'",
    $sort = "Date DESC",
    $join = "",
    $limit = "{$SQL_start}, $itemsPerPage" // enter the number of items per page (int)
    );

    return $doSet ? $doSet : false;
    }

    mysite/templates/Layout/Page.ss

    <% if getObjects.MoreThanOnePage %>
    <p class="pageNumbers">
    <% if getObjects.PrevLink %>
    <a href="$getObjects.PrevLink"><< Prev</a> |
    <% end_if %>

    <% control getObjects.Pages %>
    <% if CurrentBool %>
    <strong>$PageNum</strong>
    <% else %>
    <a href="$Link" title="Go to page $PageNum">$PageNum</a>
    <% end_if %>
    <% end_control %>

    <% if getObjects.NextLink %>
    | <a href="$getObjects.NextLink">Next >></a>
    <% end_if %>
    </p>
    <% end_if %>

  • bebabeba
    avatar
    Community Member
    111 posts

    Re: how to make Pagination on my PageHolder Link to this post

    H!
    I need to do something like this but data that I need to paginate, are the result of my query.
    Can you help me to print 10 result for page please?I'm unable to realize correctly..
    This is the function with my query.

    function Conn()
       {   global $db_pandora;
        $record=$db_pandora->query('SELECT * FROM mm_ville LIMIT 0, 30');

        $rec=array();
       
    while($rec[]=$record->nextRecord())
    { }

    $doSet = new DataObjectSet();

    foreach($rec as $key)
    { $record = array(
    'Id' => $key['id'],
    'Nome' => $key['name'],
    );
    doSet->push(new ArrayData($record));}

    return $doSet;
       }
       

    1049 Views
Page: 1
Go to Top

Currently Online: Euphemismus

Welcome to our latest member: jonchamberlain

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

Comments on this website? Please give feedback.