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

Help with Pagination

Go to End

3 Posts   699 Views


Community Member, 17 Posts

4 November 2011 at 7:02am

Edited: 04/11/2011 7:04am

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;


Forum Moderator, 5521 Posts

4 November 2011 at 6:21pm

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


Community Member, 17 Posts

4 November 2011 at 10:41pm

Edited: 06/11/2011 10:52am

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