Reputation: 4017
I'm pretty new to Zend digging the docs but i can't find a good way to get the parameter i passed to my action...
Here is my uri :
/entreprise/name/foo
I would like to extract the name, foo
. I'm actually able to get the action name with
$this->getRequest()->getActionName();
or the URI with
$this->getRequest()->getRequestUri();
With these two data i can parse the second string and get the name of my entreprise, but i quite surprised there is no best way to do this...
Is there a best to way to it ?
Upvotes: 0
Views: 90
Reputation: 1200
Get the action name with:
$this->getRequest()->getActionName();
And additional data passed to this action by GET with:
$name = $this->_getParam('name', NULL);
This will get the GET-Value name
if passed by URI, if not $name
is set to null.
Edit:
As mentioned in the comments the way to pass vars is a bit different. Change it to
/entreprise/name/var/foo
And you'll be able to access foo
this way:
$var = $this->_getParam('var', NULL);
Upvotes: 1
Reputation: 175
In the following URI : /entreprise/name/foo
if entreprise
is your controller and name
is your action, then the additional parameter will be used to call your action so you can get it by doing the following:
public function nameAction( $name = null )
{
// $name == "foo"
}
Upvotes: 0