In view mode, you can use this snippet. You can use this snippet everywhere.
Yii::app()->createUrl();
But for me it is better to define the url in the controller action and use just $ some_url var in the view.
class SomeController extends Controller { public function actionSomeAction() { $params = array( 'key1' => 'value1', 'key2' => 'value2', ); $myUrl = Yii::app()->createUrl('controller/action', $params); $this->render('some_action', array( 'my_url' => $myUrl )); } }
source share