Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Add prefix to urls in CakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.20k
    Comment on it

    CakePHP has power to do a lot with conventions by using routes. Its additionally possible to utilize custom prefixes adjacent to your admin routes for extra flexibility. Prefix routing can be enabled from within the core configuration file by setting the prefixes with Routing.prefixes.

    Configure::write('Routing.prefixes', array('admin'));
    

    We can create our prefix route as follows:

    Router::connect('/employer/:controller/:action/*', array('prefix' => 'employer', 'employer' => true));
    

    Creating links to your prefixed actions:

    echo $html->link('Edit employer', array('controller' => 'users', 'action' => 'edit', 'employer' => true, 1));
    

    This will create link as : /employer/users/edit/1

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: