view - Cakephp route and prefix -


i have problem routes on cakephp. let me explain. i'm using authentication through auth component. have routing prefix called account. when want edit user, i'm calling users controller give me url :

/account/users/edit/5 

what want have url :

/account/edit/5 

so change router :

router::connect('/:prefix/edit/:id',     array('controller' => 'users', 'action' => 'edit'),     array('pass' => array('id'), 'id' => '[0-9]+') ); 

which work when i'm trying access /account/edit/5

my problem located in view, how can access route using html link helper?

so far, i'm doing :

'/'.$this->session->read('auth.user.role').'/edit/'.$this->session->read('auth.user.id') 

but it's not clean in opinion. want use helper

thanks lot help

using prefix "account" mean needing action "account_edit" in controller. that's not want. why put "id" in url when it's there in session? why not use url "/account" users , id (and role if required) session in action?

router::connect('/account',     array('controller' => 'users', 'action' => 'edit') ); 

this clean way generate required url:

$this->html->link('account', array(     'controller' => 'users',     'action' => 'edit' )); // return url "/account" 

in general use array form specify url benefit reverse routing.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -