Wednesday, 4 March 2015

Cakephp Route

If you want like this

example.com/article/show-by-day.html
example.com/article/slug-post.html

Shows above url in route file like this

Router::connect('/article/show_by_day',array('controller' => 'posts', 'action' => 'show'), array('pass' => array('show_by_day')));

Router::connect('/article/slug-post',array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug')));

Router::connect('/article/slug-post/:slug', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug')));


if route like
Router::connect('/account', array('controller' => 'clientcontacts', 'action' => 'index', 'account' => true));

then its controller function is

public function account_index() {

}
 its view file is account_index.ctp

 if you want to call index function in user controller using name
 eg: admin/users/index i.e admin_index function 

0 comments:

Post a Comment