我在尝试让我的蛋糕应用程序根据页面的 url 在单个页面上显示数据库中的项目时遇到问题...例如,我想显示“派对”类别中的项目,然后输入“mydomain” .com/All/party”,然后我会在该页面上获得该类别中所有项目的列表。
这是我的代码,但我从路线获得的页面是空白的:
我的路线.php:
Router::connect('/categories/:name', array(
'controller' => 'All', 'action' => 'categories'
),
array(
'pass' => 'catname',
'catname' => '[a-zA-Z0-9]+'
));
我的 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');
}
任何帮助,将不胜感激。