0
votes

I have a link with Html helper in a admin_add.ctp view inside the cakeDC users plugin. My problem is the action is not used and the controller value is used for the action instead and 'users' is used as the controller.

I think it may be because routes is interfering. Not sure though.

The link I am getting is

/admin/users/books

The link I am looking for

/admin/books/index

Controller is books and the action is admin_index

echo $this->Html->link('List Books <i class="fa fa-chevron-right"></i>', 
    array('controller' => 'books', 
          'action' => 'index', 
          'plugin' => false,), 
    array('escape' => false));

routes.php

Router::connect('/', array('controller' => 'books', 'action' => 'index', 'home'));
Router::connect('/admin', array('controller' => 'books', 'action' => 'index', 'admin' => true));

CakePlugin::routes();
Router::parseExtensions('json', 'xml');
Router::connect('/users', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/users/index/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/admin/users/:action/*', array('plugin' => 'users', 'controller' => 'users', 'prefix' => 'admin', 'admin' => true));
Router::connect('/users/:action/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/users/users/:action/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/login', array('plugin' => 'users', 'controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('plugin' => 'users', 'controller' => 'users', 'action' => 'logout'));
Router::connect('/register', array('plugin' => 'users', 'controller' => 'users', 'action' => 'add'));
1

1 Answers

1
votes

Try

'plugin' => null

instead of

'plugin' => false 

and add

 'admin' => true

if you'not already on an admin page.