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.

General Questions

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

Help with Pagination


3 Posts   565 Views


4 November 2011 at 7:02am (Last edited: 4 November 2011 7:04am), Community Member, 15 Posts

Wrote a function below to search the products (custom search). It is returning me all the valid records.... No problems at all. Want to introduce pagination. Would somebody help please.

function ProductSearch() {
   global $databaseConfig;
   $query = new SQLQuery();
   $query->select = array(
   $query->where("ShowInSearch = 1 AND ClassName = 'Product' AND Title LIKE '%" . mysql_real_escape_string($srchProduct)");
   $query->orderby("Title ASC, ID ASC");
   $result = $query->execute();
   $plist = new DataObjectSet();
   foreach($result as $DataRow) {
      $plist->push(new ArrayData($DataRow));

   } else {
      $plist = NULL;
   return $plist;


4 November 2011 at 6:21pm Forum Moderator, 5511 Posts

If you have a DataObjectSet then pagination functions are built it. You can see an example of it -


4 November 2011 at 10:41pm (Last edited: 6 November 2011 10:52am), Community Member, 15 Posts

Thanks Willr, Looked at SS code to know the syntax.. Used DataObject with filter....