UPDATE 20100817: rather than using the [php]'admin' => false[/php] part below, check out [php]$this->params['prefix'] = false[/php]. This seems to work for the prefix routing in the 1.3.x series, which has taken the place of admin routing in the older pre-1.3 versions of Cake.
This confused me for a while because I couldn't find appropriate documentation after much searching. Many CakePHP Auth/Acl tutorials show setting a loginAction like this in a controller's beforeFilter:
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
That's great and it redirects to the correct path /users/login... unless you happen to have admin routing set up. If so, then it rather points you to /admin/users/login which probably isn't intended or desired. I couldn't and stil can't find sufficient documentation to explain how to set that variable, but one blurb in the CakePHP book shows an additional array key-value pair of admin=>false. So I tried it like this:
$this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
Behold! It actually worked. Since I can't find the docs, I'll assume that the controller (app_controller in my case) reads the admin key/value and interprets it to mean, "If you're accessing admin routed pages, turn off admin routing before rendering this path." Unfortunately, that's only a guess. Some additional testing could help to identify how it works, but I'm just concerned with changing the path for plain old admin routing right now.
Comments
Dan Moore (not verified)
Sat, 2011-06-18 11:21
Permalink
Thanks
Thanks so much! This was just my issue. Only comment is that you want to make sure false has no single quotes around it, just as you have in the above example. I, by habit, put single quotes around it, which won't get you the behavior you want.
Add new comment