Yii CreatUrl not returning the full URL

You just can't seem to get the URL that you expect and all the forums say just call createUrl and it'll do everything for you!

Na-ugh! Wrong!  It's returning just the action - or the controller/action but not the module.

First

First check your UrlManager rules because these are central to how createUrl builds the URL. If you've left out a "/" or your URLs are ending in "/"s then createUrl will get confused.

Then ...

Check that you are calling Yii::app()->controller->createUrl (which can often be $this->createUrl() ) rather than Yii::app()->createUrl() as the latter will not return relative URLs!

 

That's it - you should be working now

Did you know you can hire me?

I take on projects of all sizes. From Consulting to large Development Projects.

If you're starting a new Yii project and would like some help to get setup and running or you need some help with a particular module or you just need someone to develop the whole dang thing, then just ask ...


Leave a Comment

twitterfacebookgooglelinkedin https://me.yahoo.com