Hide
on 5/9/06

Routes are a great feature, but if you try using them with Plugins you might find that you start pulling your hair out. Fear not however, there's always a solution and it's usually not that difficult. If you use routes of the form below, you can map directly to a plugin's page:

  1. <?php
  2. $Route->connect('/Something/*', array('controller' =>
  3. 'PluginName', 'action' => 'ControllerName', 'Action'));
  4. // Cake 1.2 syntax
  5. Router::connect('/Something/*',
  6. array('controller' => 'PluginName', 'action' => 'ControllerName', 'Action'));
  7. ?>

Easy when you know how.

One word of warning though, the first parameter in this route has a default which is the controller action. This means that if you create route which expect parameters (as I did in the example) it will work with no parameters, but if any parameters are passed the first one will be understood to be the method name.

I suspect that at some point in the future, it'll be possible to directly specify the plugin in the route, but until then... ;)

0 Responses to Plugins and Routes