Question

Does anybody have examples of setting up the routes.php table when using plugins and prefix routing in CakePHP

e.g.

A shops controller, using the manage prefix to access certain management functions for the seller.

So /manage/shops/edit maps to manage_edit in shops_controller.php

and then placing this in /plugins/shops

Was it helpful?

Solution

In your core.php there is a configuration value called: Routing.prefixes you need to set the manage prefix there:

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

Now all calls to URLs like /manage/controllerName/actionName will go to: controllerName::manage_actionName

and all calls to URLs like /admin/controllerName/actionName will go to: controllerName::admin_actionName

For plugin routing in the routes.php file:

Router::connect('/shops/edit', array('plugin' => 'pluginName', 'controller' => 'shops', 'action' => 'edit'));

This is all that is needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top