I am having problems trying to get my cake application to display items from the database on a single page based on the url of the page... For example I want to display items that are in the "Party" category and I type "mydomain.com/All/party" in the address bar and I get a list of all the items in that category on that page.
This is my code but the pages I am getting from the route is blank:
My routes.php:
Router::connect('/categories/:name', array(
'controller' => 'All', 'action' => 'categories'
),
array(
'pass' => 'catname',
'catname' => '[a-zA-Z0-9]+'
));
my AllController.php:
function categories($catname = null) {
$options = array(
'conditions' => array('Category.name'=>$catname)
);
$Category = $this->Category->find('all', $options);
$this->set('Category', $Category);
$this ->render('/All/categories');
}
Any help would be appreciated.
I don't get at all the code you just posted, but what you want to achieve is quite trivial:
In ProductsController:
That's it. You may want to reuse the index action if you don't need a separate view template for that, in that case just set the conditions (for example to the Paginator component) and call
$this->setAction('index')