Permalink
Browse files

Updated to work with new Filter Module

  • Loading branch information...
1 parent 135d7be commit 5b17acb8b56bc5a93a47abad3bb54b863ee217af @arambalakjian committed Dec 21, 2013
Showing with 8 additions and 15 deletions.
  1. +6 −13 code/Pages/DataObjectAsPageHolder.php
  2. +2 −2 composer.json
View
19 code/Pages/DataObjectAsPageHolder.php
@@ -31,19 +31,13 @@ public function getSettingsFields()
/*
* Get Items which are to be displayed on this listing page
*/
- public function FetchItems($itemClass, $filter = '', $sort = Null, $joins = Null, $limit = Null)
+ public function FetchItems($itemClass, $filter = null, $sort = Null, $limit = Null)
{
- $results = $itemClass::get()->where($filter);
+ $results = $itemClass::get();
- if($joins)
+ if($filter)
{
- foreach($joins as $type => $join)
- {
- if($results->hasMethod($type))
- {
- $results = $results->$type($table, $join);
- }
- }
+ $results = $results->filter($filter);
}
if($sort)
@@ -112,13 +106,12 @@ public function Items($limit = null)
{
//Set custom filter
$where = ($this->hasMethod('getItemsWhere')) ? $this->getItemsWhere() : Null;
+
//Set custom sort
$sort = ($this->hasMethod('getItemsSort')) ? $this->getItemsSort() : $this->stat('item_sort');
- //Set custom join
- $join = ($this->hasMethod('getItemsJoin')) ? $this->getItemsJoin() : Null;
//QUERY
- $items = $this->FetchItems($this->Stat('item_class'), $where, $sort, $join, $limit);
+ $items = $this->FetchItems($this->Stat('item_class'), $where, $sort, $limit);
//Paginate the list
if(!$limit && $this->Paginate)
View
4 composer.json
@@ -12,7 +12,7 @@
],
"require":
{
- "silverstripe/framework": "3.*",
- "silverstripe/cms": "3.*"
+ "silverstripe/framework": "3.1.*",
+ "silverstripe/cms": "3.1.*"
}
}

0 comments on commit 5b17acb

Please sign in to comment.