Setting the ‘admin’ path using $html->link

Usually CakePHP can work out when link needs to be within the /admin/ section of your site. Sometimes however it needs a little help. When this happens you need to add 'admin' => true to the list of parameters.

echo $html->link($data['SomeModel']['name'], array( 'controller' => 'some_controller', 'action' => 'index', 'admin' => true)); 

2 thoughts to “Setting the ‘admin’ path using $html->link”

  1. It’s also worth noting that if you’re stuck in the admin section, you can use ‘admin’ => false to pop you out again.

  2. Cheers Ian

    I had no idea about setting ‘admin’ => false

    I guess the usual way of escaping is to hard code you link targets – but if there is a built in method, its much better to use that.

Comments are closed.