I am using Cakephp 1.2. I should be able to sort by A-Z or Z-A with the paginate. However, I got this error below. No much information found in the other resources. please help.
Notice (8): Undefined variable: paginator [APP/views/elements/products.ctp, line 25] Fatal error: Call to a member function sort() on a non-object in /Applications/MAMP/htdocs/development03/app/views/elements/products.ctp on line 25
Controller
var $helpers = array('Html','Form','Ajax','Javascript', 'Text');
// Pagination
var $paginate = array('limit' => 8, 'page' => 1,'order'=>array('Product.name' => 'asc'));
function lists() {
$categories = $this->Category->find('all', array('order' => 'Category.id ASC' ));
$categories = $this->Category->buildCategories($categories, $this->passedArgs['c']);
$children_ids = $this->Category->getChildCategories($categories, $this->passedArgs['c'], true);
$allCatIds = array_merge(array($this->passedArgs['c']), $children_ids);
//return lists
return $this->Product->lists($allCatIds);
}
Element
<?php
$products = $this->requestAction("/products/lists/c:$catId/");
?>
<?php echo $paginator->sort('Name', 'name', array('title' => 'Sorting Title Alphabetically','class' => 'normalTip')); ?>
<?php foreach ($products as $product): ?>
...
<?php endforeach; ?>