Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Accessing default params

I have a route that looks like this:

        $router->add("/{uid:[0-9]+}/:params", "User::view");

In my controller, I want to be able to distinguish between the case where the user arrives at the page via and

I'm trying to do this by checking $this->dispatcher->getParams(), but getParams() only seems to give me the uid and not any additional parameters passed. What am I doing wrong?

Thanks so much!


Try change route to:

$router->add("/{uid:[0-9]+}/:params", array("controller" => "user", "action"=> "view", "params" => 2));

and check $this->dispatcher->getParams() output.

edited Jun '15

Thanks Paulius!

What would my action definition look like? public function viewAction($uid) or public function viewAction()?


Seems like in this case it wouldn't pass any parameters to the action and I'd have to get uid via $this->dispatcher->getParams() too.

Also, I was making a mistake capitalzing the first letter of the controller name. Looks like you need to do that in the shorthand notation but not in the full notation. So confusing!

Thanks though. It works now!