21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 360 Views |
-
Help with Pagination

4 November 2011 at 7:02am Last edited: 4 November 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(
"Title",
"Content",
"URLSegment"
);
$query->from("xx_xxx");
$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;
} -
Re: Help with Pagination

4 November 2011 at 6:21pm
If you have a DataObjectSet then pagination functions are built it. You can see an example of it - http://doc.silverstripe.org/old/private:recipes:pagination
-
Re: Help with Pagination

4 November 2011 at 10:41pm Last edited: 6 November 2011 10:52am
Thanks Willr, Looked at SS code to know the syntax.. Used DataObject with filter....
Sorted....
| 360 Views | ||
|
Page:
1
|
Go to Top |


