» Welcome Guest !
Create Your Own Network Now!
Techsailor

Prefix Routing home > Forum Main> CakePhp > Prefix Routing

Reply to Topic

  • #1 Reply to Post Nguyen Khanh An
    on 2009/7/30 16:43:00

    Extracted from http://book.cakephp.org/view/544/Prefix-Routing

    Many applications require an administration section where privileged users can make changes. This is often done through a special URL such as /admin/users/edit/5. In CakePHP, admin routing can be enabled from within the core configuration file by setting the admin path for Routing.admin.

    Configure::write('Routing.admin', 'admin');
    1. Configure::write('Routing.admin', 'admin');

    In your controller, any action with an admin_ prefix will be called. Using our users example, accessing the url /admin/users/edit/5 would call the method admin_edit of our UsersController passing 5 as the first parameter.

    You can map the url /admin to your admin_index action of pages controller using following route

    Router::connect('/admin', array('controller' => 'pages', 'action' => 'index', 'admin' => true)); 
    1. Router::connect