I have a product site that basically uses search filters to display the products all good basically have it working you select some filters and press go and it will return the products great.
My question is I would like to call the action 'search' on the controller without posting the form so by default it will return all of the products until the user selects some filters and presses go.
class ProductPage_Controller extends Page_Controller {
...
public function init()
{
parent::init();
if(!isset($_POST)) {
return $this->search();
}
}
public function search()
{
// do stuff return all results or results if $_POST filters set
return $this->customise($data)->renderWith(array('ProductPage', 'Page'));
}
}
Can this be done or is there an easier way?