Yii URL Tutorials

Yii CHttpRequest

CHttpRequest is equal to ‘$_SERVER’. we are using ‘$_SERVER’ variable to get the details of request, scripts, headers etc. We can get this information using CHttpRequest class. We can access the CHttpRequest via Yii::app()->request. It will return browser accept types, baseurl, csrftoken, csrftoken name, host name, request type [POST, AJAX, GET, PUT, DELETE], request Uri, url, url Referrer, user Agent, user Host Address and moreYii::app()->request->acceptTypesYii::app()->request->baseUrlYii::app()->request->csrfTokenYii::app()->request->csrfTokenNameYii::app()->request->hostInfoYii::app()->request->isAjaxRequestYii::app()->request->isDeleteRequestYii::app()->request->isFlashRequestYii::app()->request->isPostRequestYii::app()->request->isPutRequestYii::app()->request->requestUriYii::app()->request->urlYii::app()->request->urlReferrerYii::app()->request->userAgentYii::app()->request->userHostAddressRedirect ScriptNote: sitepath is “”Yii::app()->request->acceptTypesaccetTypes is […]... Read More »

Yii Current Url

To Get Current UrlGet Action NameGet Controller NameTo Get Current Urlecho Yii::app()->request->requestUri; Get Action Name//Anywhere Yii::app()->controller->action->id //Inside Controller public function beforeAction($action) { $actionId = $action->id; .......... } Get Controller Name// Anywhere Yii::app()->controller->id //Inside Controller echo $this->getId();... Read More »

CHtml Link

CHtml::link() methodLinking to a controller actionLinking to a controller action with query string parametersLinking to a controller action with multiple query string parametersLink opening a new pageLinking to a controller action inside the actual controllerLinking to a controller action from the site root Linking to a controller action from another moduleLinking to a controller action from the same moduleLinking to a controller action via POST with confirmation dialogLinking to a […]... Read More »