In the view that you wish to use add the following code for the back link.
CHtml::link('Back',Yii::app()->request->urlReferrer);
In the view that you wish to use add the following code for the back link.
CHtml::link('Back',Yii::app()->request->urlReferrer);
Getting error: Bad Request The CSRF token could not be verified: when CSRF has been enabled in the Yii Framework and I’m clicking on a linkButton within a form. Add ‘YII_CSRF_TOKEN’ => Yii::app()->request->csrfToken to the params array in the linkButton Example <?php echo CHtml::linkButton('Register', array('submit' => ' '...
In the view that you wish to use add the following code for the Email link.
CHtml::mailto($data->email)
NOTE: $data->email contains the email address, replace this variable with the relevant email address or variable that contains the email address.
You can add the below code anywhere in your Yii Application and JQuery will be included in the rightful place in your application
Yii::app()->clientScript->registerCoreScript('jquery');
Include the following code anywhere in your application [js]<span id="urn:enhancement-f9965c67-8856-e15b-a96a-9ae613690f5b" class="textannotation">Yii</span>::<span id="urn:enhancement-0ff1ff82-84ee-005a-2d01-4a27dedfa994" class="textannotation">app</span>()->clientScript->scriptMap=array( 'jquery.js'=>false...
Use the code below to obtain the server name
Yii::app()->request->serverName
The Host Address server variable forms part of the Server and execution environment information set
To get the user’s IP ADDRESS within the Yii Framework use the following code
echo Yii::app()->request->userHostAddress;
This can be called from anywhere within your Yii Framework application
The QUERY STRING server variable forms part of the Server and execution environment information set
To get the QUERY STRING within the Yii Framework use the following code
echo Yii::app()->request->getQueryString(); //The same as echo $_SERVER['QUERY_STRING'];
This can be called from anywhere within your Yii Framework application
The Request URI server variable forms part of the Server and execution environment information set
To get the URI within the Yii Framework use the following code
echo Yii::app()->request->getRequestUri(); //The same as echo $_SERVER['REQUEST_URI'];
This can be called from anywhere within your Yii Framework application
Include the following code anywhere in your application
Yii::app()->clientScript->registerCoreScript('jquery.ui');
The code abouve will register jquery-ui in your application
To get the Base URL within the Yii Framework use the following code
<?php echo Yii::app()->request->baseUrl; ?>
This can be called from anywhere within your Yii Framework application
In your main layout file always have the following code between the title tag in order to display the title <title><?php echo CHtml::encode($this->pageTitle); ?></title> Please note that conditional statements can also be use within the title tag to make displaying of the title more dynamic. You can set the title in your Controller or View files by using something similar...
Getting Error 400: The CSRF token could not be verified. when trying to delete an item using the default delete link. $this->menu=array( array(‘label’=>’Create Use’, ‘url’=>array(‘create’)), array(‘label’=>’Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id))...
$controller=Yii::app()->controller;
$action=$controller->action;
//Getting the current action
echo $action->id;
//Getting the current controller
$controller->uniqueID
Add the JavaScript code as below to your view $js = Yii::app()->getClientScript(); $js->registerScript( 'my-javascript-id', 'var value = "Hello World"; alert(value);', CClientScript::POS_END ); Yii’s CClientScript is used to place JavaScript to your views. The arguments of register script are as follows: The first argument uniquely identifies your script The second argument...
Open the main configuration file protected/config/main.php Now in the main.php file we can assign a Action or Url to homeUrl _highlight[1] = “\n\nreturn array(\n\n \’basePath\’=>dirname(__FILE__).DIRECTORY_SEPARATOR.\’..\’,\n\n \’homeUrl\’=>array(\’site/login\’),\n\n ….\n\n”; return array( ...
Yii::app()->theme = 'ThemeName';
The above code can be set anywhere in your Yii Application to change the current Theme.
Use the getAttributeLabel() method (available since v1.1.4)
Code Example:
Products::model()->getAttributeLabel('brand_id')
The above example gets the attribute label for the brand_id attribute in the model Products.
This can be done using the registerCss() method of the CClientScript class. CClientScript manages JavaScript and CSS stylesheets for views. registerCss()registers a piece of CSS code. Place code similar to the example code below in your View Yii::app()->clientScript->registerCss('customCSS',<<<CSS li { font-weight: normal; } CSS ); In the code above the first parameter...