1

I have this link:

<a href="<?php echo $this->url(array('controller'=>'index','action'=>'form'),NULL,TRUE);?>">
                                    Form
</a>

With this I get something like:

http://foo.com/form

I need to pass a param to the URL with this link. So that I can have something like this instead:

http://foo.com/form?bar=1231

How can we accomplish this ?

Thanks in advance.

MEM
  • 30,529
  • 42
  • 121
  • 191
  • 1
    If you aren't gonna be following the Zend routing with the link, why are you using a view helper to create the link? You could just append the "?bar=1231" after the created url in the HTML. – Niklas Jul 04 '11 at 10:57
  • Thanks. I will just append that. If you answer that. I will mark it as an answer. Indeed it was that simple queston. :) – MEM Jul 04 '11 at 11:18

2 Answers2

3

In ZF, URL parameters are passed as /param-name/param-value. So if http://foo.com/form/bar/1231 would satisfy you, you could do like this:

<?php echo $this->url(array('controller'=>'index','action'=>'form', 'bar'=>'1231'),NULL,TRUE);?>
Marcin
  • 215,873
  • 14
  • 235
  • 294
1

The URL view helper is used to create links using the Routes setup with your application. If you aren't following the routes setup, then there isn't much point in using the view helper, and instead you could just append the created url you got from the view helper with the ?bar=1231.

<a href="<?php echo $this->url(array('controller'=>'index','action'=>'form'),NULL,TRUE)."?bar=1231";?>">
                                    Form
</a>
Niklas
  • 29,752
  • 5
  • 50
  • 71
  • They will not be different from normal urls, in zend framework we ought not to use "?" query string – palAlaa Mar 19 '12 at 06:19