Matthias,

I agree that 'controller' and 'action' do not belong in the parameter list.  And they are not always there even.  If you use the default router (well for me at least) you do not get those parameters.  With the rewrite router you do.  and with the MJS stuff, you get them as well.

Renan,

With the Zend Framework default router, the URL format is:
   /controllerName/actionName/paramName/paramValue/paramName/paramValue

And you use:

  $this->_getParam('paramName');
  or
  $this->_getParam('paramName', 'defaultValue');

If you do not specify a default value, it will return null if the parameter is not found.

Example:

/news/view/article/11226

You could call:

  $this->_getParam('article', '0') and get back '11226'  (keep in mind it is a string at this point)

If you want to pass just values after the controller/action, you will need something a bit more advanced that will let you specify how routes are matched.

Hope that helps.  Lee


On 10/12/06, Matthias Zitzmann <[EMAIL PROTECTED]> wrote:
Oh, I overread the paragraph with the alternate methods
($this->_action->get...Name()).

I haven't tested it yet, but this seems to be more efficient. In this
case, controller and action should be removed from *Param* methods.


Matthias



Matthias Zitzmann wrote:
> I think, it isn't the best way, there should be a set of separate
> methods. In this way, you aren't able to define a parameter called
> action, this variable is overwritten by the controller action.
> However, I think that this is currently the best way because it works
> with user defined routes, too.
>
> With _getAllParams() you will get an associative array containing all
> paramters. If you only want to get one specific parameter, try to use
> _getParam('PARAMNAME'), e.g. $this->_getParam('controller').
>
>
> Matthias
>
> Renan Gonçalves wrote:
>> Yes, this method is functionaly.
>> ehehehe
>>
>> In the manual don't say that things :(.
>> And now, How I can get additionals param ?
>> I.E: /controllerName/actionName/addtionalvalue1/addtionalvalue2
>>
>>
>> Thanks for all.
>> (Please, give me a good website with Zend Framework Tutorial's)
>>
>> 2006/10/11, Lee Saferite <[EMAIL PROTECTED]>:
>>>  I currently use:
>>>
>>> $this->_action->getControllerName()
>>> $this->_action->getActionName()
>>>
>>> Not sure if this is the best way.
>>>
>>> Lee
>>>
>>>
>>> On 10/11/06, Matthias Zitzmann <[EMAIL PROTECTED]> wrote:
>>> > Try to use $this->_getParam('controller') and
>>> $this->_getParam('action')
>>> > for that.
>>> >
>>> >
>>> > Matthias
>>> >
>>> >
>>> > Renan Gonçalves wrote:
>>> > > How I can get Controller and Action name ?
>>> > >
>>> > > Thank's
>>> >
>>>
>>>

Reply via email to