Created
August 31, 2010 23:46
-
-
Save benmanns/559987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GroupsController extends AppController { | |
var $name = 'Groups'; | |
var $paginate = array( | |
'fields' => array( | |
'Group.id', | |
'Group.icon', | |
'Group.name', | |
'GroupCategory.name', | |
'Group.location', | |
'Group.description', | |
'Group.website', | |
'Group.created', | |
'SUM(Donation.amount) AS donations', | |
), | |
'joins' => array( | |
array( | |
'table' => 'donations', | |
'alias' => 'Donation', | |
'type' => 'LEFT', | |
'conditions' => array('Donation.group_id = Group.id'), | |
), | |
), | |
'limit' => 8, | |
'order' => array( | |
'Group.name' => 'asc' | |
), | |
'group' => 'Group.id', | |
); | |
function admin_index() { | |
if(!empty($this->data)) { | |
$this->paginate['conditions'] = array( | |
'MATCH (Group.name, Group.description) AGAINST (? IN BOOLEAN MODE)' => array($this->data['Group']['q']) | |
); | |
} | |
$groups = $this->paginate('Group'); | |
$this->set(compact('groups')); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please help! I am trying to have the
donations
column sortable, but visiting the urlhttp://localhost/admin/groups/index/page:1/sort:donations/direction:asc
does nothing. If I change the$paginate
array to:the sort works, but after clicking on the sort tab (resulting in the url above) everything breaks.