I was lazy (deep apologies!) and should have researched first. I have
solved it:
Router::connect('/controller/index/:parameter/*', array('controller'
=> 'controller', 'action' => 'index'), array('pass' => array
('parameter')));
...and then change my index function:
function index($parameter=null) {
..and then I can refer to $parameter
On Dec 17, 5:50 am, Jeremy Burns <[email protected]> wrote:
> In routes.php file, I have this entry:
>
> Router::connect('/:controller/add', array('action' => 'edit',
> 'origAction' => 'add'));
>
> ...which works great. It sends all add requests to the edit functions
> and sets a variable called origAction to add where appropriate (this
> is taken from Matt Curry's excellent book
> -http://www.pseudocoder.com/free-cakephp-book/).
>
> However, this does not work if I pass in a named parameter. For
> example:
>
> /controller/add/parameter:4
>
> ...does not redirect to the edit function. Instead it tells me I need
> to create the add function in my controller.
>
> I haven't done much routing and this is probably quite
> straightforward. Can someone advise me how to adjust the routing so
> that this is directed to the edit function and allows me to collect
> the named parameters there, please?
>
> I'd like to be able to do this:
>
> if (! empty($this->params['named']['parameter'])):
>
> ...in my edit function.
>
> Thank you.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en