Can i hide controller and view name cake php 2?

爷,独闯天下 提交于 2019-12-02 05:30:38

Your solution

For static text try this:

Router::connect('/this_is_test', array(
      'controller' => 'home', 
      'action' => 'this_is_test OR any_other action name'
));

If it's dynamic

Router::connect('/:id', 
    array('controller' => 'home', 'action' => 'index'),
    array(
        'pass' => array('id'),
        array('id' => '[A-Za-z]')
    )
);

References: Cakephp2.x Route

I hope I knew what you really want to achieve. You can place the Route in the last position. Here is the reference .

Other option would be to use alias for your controller. So you call your controller some thing else and set a new name for your controller then call it in you Route.

If this doesn't work then you would need to write a bespoke Component in order to help you to do that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!