Jump to content

CakePHP - Routing messing up links


CrimpJiggler

Recommended Posts

In my routes.php file, I added this:

Router::connect('/Compounds/:action/*',array('controller' =>  'Substances'));
Router::connect('/Preparations/:action/*',array('controller' => 'Substances'));
Router::connect('/Formulations/:action/*',array('controller' => 'Substances'));
Router::connect('/Plants/:action/*',array('controller' => 'Substances'));

and now, the links generated by Paginator all point to Compounds, even when thats not the model which has been loaded with $this->Paginator->paginate($model);

 

If I change the order, so its:

Router::connect('/Plants/:action/*',array('controller' => 'Substances'));
Router::connect('/Compounds/:action/*',array('controller' =>  'Substances'));
Router::connect('/Preparations/:action/*',array('controller' => 'Substances'));
Router::connect('/Formulations/:action/*',array('controller' => 'Substances'));

then all the paginator links point to Plants. The same problem occurs when I redirect to $this->redirect(array('action' => 'index'));

without specifying the controller. So it seems the routes page is altering the links which don't specify a controller. This wouldn't be a problem (on the contrary, it'd be helpful) if it would add the correct controller to the links, I don't know why its adding Compounds to every link.

Link to comment
https://forums.phpfreaks.com/topic/285964-cakephp-routing-messing-up-links/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.