Reputation: 790
I'm just learning Yii framework and creating URLs in a controller is confusing me. The createUrl() method is in both CApplication and CController but it behaves differently. I can't really figure out, when to use which?
Upvotes: 2
Views: 1688
Reputation: 875
I try to use the CControler->createUrl();
when I'm in a controller, this includes the views.
When I'm in a component or another globaly used object, I'll use the Yii::app()->createUrl();
Upvotes: 0
Reputation: 355
in Yii::app()->createUrl() you must provide a contoller/action path.
In the controller method, you don't need specify the controller ID, sou you only pass the action to createUrl.
See http://www.yiiframework.com/doc/api/1.1/CApplication#createUrl-detail and http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail
Upvotes: 2