Alex Rivera | Logout

Routing: 'admin' => true vs 'prefix' => 'admin in CakePHP

Asked 2010-06-30T18:30:45.813
14

Hi I'm setting up admin routing in CakePHP.

This is my current route:

Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages', 'action' => 'display', 'home'));

It works fine, but I don't understand what the difference between 'admin' => true, and 'prefix' => 'admin' is.

When I omitted 'prefix' => 'admin', the router wouldn't use admin_index and would instead just use index. So what's the point of 'admin' => true?

Edit
Report

1 Answer

4
// Go into a prefixed route.
echo $html->link('Manage posts', array('manager' => true, 'controller' => 'posts', 'action' => 'add'));

// leave a prefix
echo $html->link('View Post', array('manager' => false, 'controller' => 'posts', 'action' => 'view', 5));
answered 2010-09-26T11:45:30.067

Your Answer