I want to connect the following routes:
register/about_you
my_profile/edit/about_you
...to the same action. But I want the second route to bring in a parameter that I can use to identify that we are on the edit page, not registration.
I currently have in my routes.php:
Router::connect('/register/:action/*',
array(
'controller' => 'registration'
)
);
Router::connect('/my_profile/edit/:action/*',
array(
'controller' => 'registration',
'edit' => 1
)
);
This works to connect the URLs above to the correct place - and I can use $this->params['edit']
in the controller. However, when I try to build a link, using
Router::url(array('controller' => 'registration', 'action' => 'about_you', 'edit' => 1, $i));
I get
/register/about_you/0/edit:1
Instead of
/my_profile/edit/about_you
What am I doing wrong?
Did you try interchanging it like this?
Router::connect('/my_profile/edit/:action/*',
array(
'controller' => 'registration',
'edit' => 1
)
);
Router::connect('/register/:action/*',
array(
'controller' => 'registration'
)
);
If it is like this, you'll get /my_profile/edit/about_you/0