【问题标题】:cakephp change default action for controller (i.e. from "index")cakephp 更改控制器的默认操作(即来自“索引”)
【发布时间】:2011-03-31 03:37:24
【问题描述】:

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

【问题讨论】:

    标签: cakephp controller action


    【解决方案1】:

    知道了。对于其他人:

    文件/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

    【讨论】:

      【解决方案2】:
      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'));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-02
        • 1970-01-01
        • 1970-01-01
        • 2016-04-03
        • 1970-01-01
        • 2018-12-16
        • 2014-07-17
        相关资源
        最近更新 更多