CrimpJiggler Posted February 5, 2014 Share Posted February 5, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/285964-cakephp-routing-messing-up-links/ Share on other sites More sharing options...
CrimpJiggler Posted February 7, 2014 Author Share Posted February 7, 2014 I fixed the pagination issue by adding this: $this->Paginator->options(array( 'url' => array( 'controller' => correct_value ) )); to the view page, where correct_value is the pseudocontroller value that should appear in the link URL. Quote Link to comment https://forums.phpfreaks.com/topic/285964-cakephp-routing-messing-up-links/#findComment-1468038 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.