2
votes

I am using cakephp 2.0 ACL with Auth components. My groups table contain 3 types admin, manager and user

I enabled the Routings in Core.php file

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

default.ctp file contains following line to link to products:

   $this -> Html -> link(__('Products'), array('controller' => 'products','action'  => index'));

when i logged in as admin the above link is http://www.example.com/admin/products/index
when i logged in as manager the above link is http://www.example.com/products/index the group name "manager" is not appending before products

I need the following output when i logged in as manager

http://www.example.com/manager/products/index               
1

1 Answers

1
votes

Try this line in the view:

$this->Html->link(__('Products'), array('controller' => 'products','action'  => index','manager'=>true));

As in, adding 'manager'=>true to the list of options passed to the HtmlHelper::link() method, or whichever prefix name you need in the URL (i.e. admin, manager...).

To work out which prefix is currently used, you can use this snippet:

$opts = Router::parse(Router::url(''));
$prefix = $opts['prefix']; // Contains 'admin' or 'manager', etc.

You can then pass $prefix=>true as an option the Html link method.