How can use Yii Bootstrap GridView in your application

This is very easy. Just need to follow few things. I suggest to browse Yii Bootstrap site for more details.

$this->widget('bootstrap.widgets.TbGridView', array(
   'type'=>'striped bordered condensed',


       array('name'=>'last_name', 'header'=>'Name'),
       array('name'=>'email', 'header'=>'Email Address'),
       array('name'=>'mobile_phone', 'header'=>'Mobile Phone'),
       array('name'=>'city', 'header'=>'City'),
       'htmlOptions'=>array('style'=>'width: 50px'),


Display input element on dropdown selection in Yii

To display an input element on dropdown selection is very easy. Just follow few steps-
Using JavaScript:
Selection dropdown 1:

<div class="row">  
   <?php echo $form->labelEx($model,'status'); ?>

   <?php echo $form->dropDownList($model,'status',
      array('onchange'=>'return checkStatus(this.value)'));

   <?php echo $form->error($model,'status'); ?>

    Hidden div. Will active if selection is true
    <div id="hiddendiv" style="display:none">                 
        <div class="row">
           <?php echo $form->labelEx($model,'category'); ?>
           <?php echo CHtml::activeDropDownList($model,'category', 
                array('prompt'=>'Select') ); ?>
           <?php echo $form->error($model,'category'); ?>
function checkStatus(obj)
       return false;               
       return false;                
By Using Yii Ajax-

In View
        <?php echo $form->labelEx($model,'status'); ?>

        <?php echo $form->dropDownList($model,'status',
        array('0' =>'In active', '1'=> 'Active'),

        array( 'onChange' => 'javascript:description()', 
        <div id="status_id"></div>
        <?php echo $form->error($model,'status'); ?>

    In Controller-
    public function actionfunctionName()
           //For only text field
           //echo CHtml::textField("Employment",'applying_position'); 

           // For Dropdownlist

           echo $form->dropDownList($model,'status',

Hope that will help us.

Create custom Input validation rules in Yii model for dependent input field

Suppose we want to create a dependent input validation rule in Yii model for dependent 2 input field. Field one is status and field two is reason. If user select a status from dropdown list then they must be fill-up reason field. If not then it will show a error message.

In model rules-

public function rules()
   return array(
   array('status', 'reasonValidators'),

and validation function-

public function reasonValidators()
  if ((int)$this->status=="Yes")
    $labels = $this->attributeLabels(); // Getting labels of the attributes
       $this->addError("reason", $labels["reason"]." cannot be blank.");
    // More dependent on type can be written here

Migrating a WordPress Site From a Local Server to Production

Migrating a WordPress site from local server(localhost) to production(live) server is very easy. Just you need to follow few steps to find your goal.

STEP 1: Upload WordPress project folder to production server using FTP client software (i.e FileZilla FTP Client)

STEP 2: Create a database in production server and keep database host name, database name, user name and password for next time use

STEP 3: Now open and edit  wp-config.php file from production server root folder (where you already uploaded project files) and update your database information

STEP 4: Now go to your local server project database by entering http://localhost/phpMyAdmin/ and  then export project database in .SQL format.

STEP 5: Now go to your production project database and import locally exported .sql file

STEP 6: After importing database go to wp_options table from production server and find option_name siteurl and then update option_value into your production website URL without forward slash in end.

Do same for option_name home (Go page 2 to find this)


Work is done. Now browse your website and find your destination.

Have fun with WordPress.




Add expires headers on your website and enhance load speed

Creare a .htaccess file with following lines and upload to your website root folder.

ExpiresActive on

# Your document html
ExpiresByType text/html "access plus 0 seconds"

# Media: images, video, audio
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"

# CSS and JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"

Check using Yslow or Page speed.

Minify Javascript and CSS files using minify extension in Yii

To minify Javascript and CSS files in Yii applications just go to following URL and then download the extension.
Then extract into extension directory and finally edit your config.php file and following lines in // application components section

'clientScript' => array(
'class' => 'ext.minify.EClientScript',
'combineScriptFiles' => true,
'combineCssFiles' => true,
'optimizeCssFiles' => true,
'optimizeScriptFiles' => false,

Now test using YSlow or Google Pagespeed.