Newbie question regarding parameters in the url

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Newbie question regarding parameters in the url

julian999
Hello,

Im new to zend framework and i am having difficulty understanding how parameters are used in the url.

Currently I am making urls using the following code -

$this->url(array('controller'=>'controllername','action'=>'actionname','paramname'=>'paramvalue'))

The problem is the parameter is staying in the url in everypage I go to following navigating to the page created using the previous code.

I realise that this is probably a ridicuously simple question but I need to be certain that I understand why this is happening as its quite a fundamental part of the framework

Any help would be greatly appreciated

Thank You

Julian
Reply | Threaded
Open this post in threaded view
|

Re: Newbie question regarding parameters in the url

Michael Crumm
Julian,

I'm going to try and provide some help, please let me know if you need further explanation.

First, from the API Docs:
------------------------
Zend_View_Helper_Url

url (line 46)

Generates an url given the name of a route.

  • return: Url for the link href attribute.
  • access: public
string url ([ $urlOptions = array()], [mixed $name = null], [bool $reset = false], [ $encode = true])
  • array $urlOptions: Options passed to the assemble method of the Route object.
  • mixed $name: The name of a Route to use. If null it will use the current Route
  • bool $reset: Whether or not to reset the route defaults with those provided
  • $encode
the value you are going to be interested in is '$reset'.  Set this to true on links where parameters should not persist.

-----------------
Example:

<a href="<?= $this->url(array('controller'=>'index','action'=>'index'), null, false) ?>">I persist params</a>
<a href="<?= $this->url(array('controller'=>'index','action'=>'index')) ?>">So do I.</a>
<a href="<?= $this->url(array('controller'=>'index','action'=>'index'), null, true) ?>">I don't</a>

Hope this points you in the right direction!

-Mike


On Mon, Dec 8, 2008 at 11:41 AM, Julian102 <[hidden email]> wrote:

Hello,

Im new to zend framework and i am having difficulty understanding how
parameters are used in the url.

Currently I am making urls using the following code -

$this->url(array('controller'=>'controllername','action'=>'actionname','paramname'=>'paramvalue'))

The problem is the parameter is staying in the url in everypage I go to
following navigating to the page created using the previous code.

I realise that this is probably a ridicuously simple question but I need to
be certain that I understand why this is happening as its quite a
fundamental part of the framework

Any help would be greatly appreciated

Thank You

Julian
--
View this message in context: http://www.nabble.com/Newbie-question-regarding-parameters-in-the-url-tp20899971p20899971.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Newbie question regarding parameters in the url

julian999
Thank you for the reply it was very helpful.

Im still a little confused however because I dont understand why by default parameters would persist surely in most situations you would not want them to.

Do you know if I am right in saying its good practice to use the views url helper when creating links.


Michael Crumm wrote
Julian,

I'm going to try and provide some help, please let me know if you need
further explanation.

First, from the API Docs:
------------------------
Zend_View_Helper_Url

url (line 46)

Generates an url given the name of a route.

   - return: Url for the link href attribute.
   - access: public

 string url ([ $urlOptions = array()], [mixed $name = null], [bool $reset =
false], [ $encode = true])

   - array $urlOptions: Options passed to the assemble method of the Route
   object.
   - mixed $name: The name of a Route to use. If null it will use the
   current Route
   - bool $reset: Whether or not to reset the route defaults with those
   provided
   -  $encode

the value you are going to be interested in is '$reset'.  Set this to true
on links where parameters should not persist.

-----------------
Example:

<a href="<?= $this->url(array('controller'=>'index','action'=>'index'),
null, false) ?>">I persist params
<a href="<?= $this->url(array('controller'=>'index','action'=>'index'))
?>">So do I.
<a href="<?= $this->url(array('controller'=>'index','action'=>'index'),
null, true) ?>">I don't

Hope this points you in the right direction!

-Mike


On Mon, Dec 8, 2008 at 11:41 AM, Julian102 <julianread@live.co.uk> wrote:

>
> Hello,
>
> Im new to zend framework and i am having difficulty understanding how
> parameters are used in the url.
>
> Currently I am making urls using the following code -
>
>
> $this->url(array('controller'=>'controllername','action'=>'actionname','paramname'=>'paramvalue'))
>
> The problem is the parameter is staying in the url in everypage I go to
> following navigating to the page created using the previous code.
>
> I realise that this is probably a ridicuously simple question but I need to
> be certain that I understand why this is happening as its quite a
> fundamental part of the framework
>
> Any help would be greatly appreciated
>
> Thank You
>
> Julian
> --
> View this message in context:
> http://www.nabble.com/Newbie-question-regarding-parameters-in-the-url-tp20899971p20899971.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>