createUrl to current route?


(Thomas Jensen) #1

Hi,

How do i make a link to the current page?

I’ve tried


$this->createUrl($this->route);

, but it doesn’t take params with it and


$this->createUrl($this->route,$_GET);

seems kind of ugly?

Thanks.


(Antonio) #2

Maybe this helps you: http://www.yiiframework.com/doc/api/1.1/CHttpRequest#getQueryString-detail


(Thomas Jensen) #3

Not really… :(


(Maschingan) #4

$this->createUrl('')


(Thomas Jensen) #5

Will it obey the url rules and add params?


(Matteo Falsitta) #6

I use without shame $this->createUrl($this->route,$_GET);


(John Fragkoulis) #7

I think the correct would be


$this->createUrl('/'.$this->route,$_GET);


(Pawel Drylo) #8

Hi,

I know this is not the answer to your question (well, maybe partial :) ), but why won’t you use url currently requested?

d


(Jacob Moen) #9

It’s better to use the current route as the URL can change depending on the URL rules.


(Konapaz) #10

Hi Zaccaria

I had create current url adding extra parameter(s) in 2-3 different ways in the past.

But I had a few problems with url rules or (I think) security weakness

Your way is short and straight full

Please let me know:

  1. Is there any problem with url manager rules ?

  2. Is there any security issue ? (hacking etc)

Thanks