I just started learning PHP,cakePHP and I am unable to sort my page. My Controller is as follows;
public $helpers = array('Html', 'Form', 'Flash', 'Paginator');
public function index()
{
$this->Post->recursive = 0;
$this->paginate = array ('limit' => 5);
$this->set('posts', $this->paginate());
$this->set('posts', $this->Post->find('all'));
echo $this->Paginator->sort('id');
}
Paginate is working fine, but for sort I get a fatal error as follows
Call to undefined method PaginatorComponent::sort()
could not find anything related to the error as well. It might be really basic but it will really help me to learn more, and I want to learn more! Any help will be appreciated. Thank you in advance!
Update:
I added the following code in my index view,
<th><?php echo $paginator->sort('Id', 'id'); ?></th>
But now I am getting the following error Call to a member function sort() on null