Skip to content

Commit

Permalink
Using PaginatedList for blog entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmullenger committed Jul 3, 2012
1 parent 31c56ca commit 697ed18
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions code/BlogTree.php
Expand Up @@ -113,8 +113,8 @@ function getCMSFields() {
"INHERIT" => "Take value from parent Blog Tree"
)));

$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
//$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
//$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));

return $fields;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public function BlogHolderIDs() {
* @param string $where
* @return DataObjectSet
*/
public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {
public function Entries($tag = '', $date = '', $retrieveCallback = null, $filter = '') {

$tagCheck = '';
$dateCheck = '';
Expand Down Expand Up @@ -208,8 +208,12 @@ public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback =

// By specifying a callback, you can alter the SQL, or sort on something other than date.
if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $filter, $limit, $order);

return DataObject::get('BlogEntry', $filter, $order, '', $limit);

$entries = BlogEntry::get()
->where($filter)
->sort($order);

return new PaginatedList($entries, Controller::curr()->request);
}
}

Expand Down Expand Up @@ -264,7 +268,9 @@ function BlogEntries($limit = null) {

$date = $this->SelectedDate();

return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date : '', null, $filter);
$list = $this->Entries($this->SelectedTag(), ($date) ? $date : '', null, $filter);
$list->setPageLength($limit);
return $list;
}

/**
Expand Down

0 comments on commit 697ed18

Please sign in to comment.