by Daniel | hits(1747)
Well today I'll share with you a small trick about Admin Routing!
As the CakePHP manual states, Admin Routing are:
"special URLs so users with administrative privileges can access special actions in controllers"
Admin Routing are a confortable way provided by CakePHP to build the backend (administrative interface) of your application faster.
I won't fully illustrate the potentiality of Admin Routing here (read the manual: Advanced Routing Configuration: Admin Routing and Webservices) but I'll rather concentrate on a small trick I recently discovered.
If in your Routing settings (app/config/routes.php) you pass a special third parameter like:
'admin'=>'1'
In order to get something like:
Router::connect('/myuri', array('controller' => 'mycontroller', 'action' => 'index', 'admin' => '1'));CakePHP will associate the request to /myuri to the method yourRoutingWord_index, where yourRoutingWord is the little magic word you decided to use for Admin Routing in your app/config/core.php
Configure::write('Routing.admin', 'yourRoutingWord');In other words, that last little parameter 'admin'=>'1', will force CakePHP to use the admin routing (yourRoutingWord_index) method of your controller instead of the usual one (index).
As you might have noticed by the use of the Configure class, here I'm speaking about CakePHP 1.2
Happy baking!
Daniel
view/hide comments | add comment
powered by 4webby.com