cakephp更改控制器的默认操作(即来自“index”)

时间:2011-03-31 03:37:24

标签: cakephp controller action

我有一些控制器我想默认为表而不是索引,因为它们以不同于我的索引页面使用的格式呈现更好。我怎么能改变这个?

2 个答案:

答案 0 :(得分:5)

知道了。对于其他人:

文件/app/config/routes.php包含路由配置,可以在那里更改默认操作。例如,

Router::connect(
   '/pages',
   array('controller' => 'pages', 'action' => 'display')
);

这会向app / pages /发送请求到“显示”操作,而不是通常的“索引”。

更多信息:http://book.cakephp.org/view/46/Routes-Configuration#!/view/46/Routes-Configuration

答案 1 :(得分:0)

The file /app/config/routes.php file change the defult controller name 


Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

to

Router::connect('/', array('controller' => 'Your defult controller', 'action' => 'your defult conroller method'));
相关问题