Integration of CKEditor in Yii Framework

1. Download CKEditor extension here

2. Put it in your app/protected/extensions/

3. In your form, write this code

<?php   $this->widget(‘application.extensions.ckeditor.CKEditor’, array(                          ‘model’=>$model,                          ‘attribute’=>’filed name’,                          ‘language’=>’english’,                          ‘editorTemplate’=>’full’,               ));?>

Export Gridview Filtered Result To Excel in Yii framework

public function actionAdmin() {
                $model=new Customer('search');
                $model->unsetAttributes();  // clear any default values
                Yii::app()->user->setState('exportModel',$model); //this can be any other storage


public function actionExportToFile() {
                //echo 'test';
                header('Content-type: text/csv');
                header('Content-Disposition: attachment; filename="report-customers-' . date('YmdHi') .'.csv"');

                $model=new Customer('search');
                $model->unsetAttributes();  // clear any default values

                $dataProvider = $model->search(false);
                // csv header
                echo    Customer::model()->getAttributeLabel("Id").",". 
                                " \r\n";
                // csv data
                foreach ($dataProvider->getData() as $data) {
                        echo "$data->Id, $data->Country_Id, $data->Gender_Id, $data->First_Name, $data->Last_Name \r\n";

5 key features to be excited about in Drupal 8

1. Manage your site’s content…from your phone. 
Anyone that’s ever administered a website knows that it’s best done while using a desktop or laptop. Much of the backend functionality simply doesn’t work, or doesn’t support mobile platforms. The Drupal 8 Mobile Initiative is a group effort to make Drupal 8 a great platform for tablets, smartphones and other mobile devices. Not only will administration go mobile but themes that are available for Drupal 8, will be responsive. This means a better experience for not only administrators, but also mobile visitors to your site.

2. Take your website around the world.
Drupal 7 supports multi-lingual functionality, but not at the level that Drupal 8 will. Imagine translating your site’s content to any one of the 110 different support languages. You’ll be able to not only translate a page’s content for a specific language, but also build views and determine what blocks should appear for that language. Translation updates will also be pushed to the site automatically to make sure your site has the latest dictionary.

3. HTML5 takes the stage. 
HTML5 is a big improvement over the current XHTML that Drupal 7 uses. HTML5 represents a giant step forward in how content is structured and presented on the web. As Dries Buytaert explains, “simply put, it (HTML 5) can provide a much better user experience on both desktop and mobile devices, and could lead to a convergence between native applications and the mobile web.”

4. Change the parameters for your views without a developer.
Views are a set of parameters which determine what content is shown on a page, what field
should be shown, in what order etc. In Drupal 7, the Views module is separate from Drupal Core and has a dependency on the CT Tools Suite. The VDC initiative has built Views into Drupal 8 core so it is available with a fresh install. This means better integration. Drupal 8 also promises to make the application of Views much easier, meaning site administrators can take control rather than relying on a more technical development team.

5. Less modules for faster page loads and reduced server load. 
Each time a page loads on a Drupal 7 site, all of the enabled modules are loaded as well
while Drupal determines which ones implement a required “hook”. Every module may not be needed for each page, and this can lead to longer load time while the user peruses the site. As part of the overall transition to the Symfony framework, Drupal 8 will load only the modules which a page needs, and not more. This will mean faster page loads for your visitors, as well as a likely decrease in the amount of run time memory required for smooth performance.

These are just a few of the many changes which are coming with Drupal 8. Lastly, for those of you who are on Drupal 6 or 7 now, have no fear; Drupal 8 will support content import tools to make your migration much more smooth.

– See more at:

How to show maintenance mode page in magento (website under construction)

If you want your Magento website to show in maintenance mode, you will have to do two things.
1. Create a file name maintenance.flag in your magento root directory. Contents under this file doesn’t matter, you can keep it empty.
2. Change the maintenance file (located in magento root -> errors -> default directory) to show proper message when user visits your website.

How to join EAV collection with Flat table in Magento

Joining tables in Magento when it comes to EAV with Flat table is quite complicated. Consider you want to join sales_flat_order table with customer EAV tables to get Customer’s firstname and lastname, it becomes difficult as customer’s name comes from customer_entity_varchar table.
Here is code for customer EAV to get customer’s full name in the collection along with all the order details.

$value = Mage::getModel('sales/order')->getCollection();
$fn = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
$ln = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');
    ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.customer_id', array('firstname' => 'value'))
    ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.customer_id', array('lastname' => 'value'))
    ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"));

Click Here to know more

Add New Custom Page Layout in Magento 1.7

Here is the Solution for adding New Custom Page Layout in Magento.
You have to create one Module for this Extra Custom Layout.

1. Create Your Module File called Love_Home.xml in app/etc/modules

Insert the following code into the file:

<?xml version="1.0"?>

2. Now create Config File of your Module called config.xml and put this file in the Following directory Structure.


Insert the following code into the file:

<?xml version="1.0" encoding="UTF-8"?>
<love_home module="page" translate="label">
<label>Home Layout</label>

3. Now you have to create Template File of your Module called home.phtml and put this file in the Following directory Structure.


Write Your Code Here... For Example

<h1><?php echo "New Custom Page Layout Successfully Created.";?></h1>

4. Finally go to CMS->Pages->Home Page->Design. You can see your New additional Custom Layout in dropdown.

Now Select "Home Layout" and Press Save Page.

Caching in Drupal

I’m talking about the core Drupal caching: page cache and block cache which are available in Drupal 7 core. Drupal 6 is similar but works a but differently because page caching was simplified for Drupal 7 (e.g. aggresive mode is now a available as a settings.php var) and the entire system also has become pluggable.

Page caching:

  • If enables, page caching will only be used for anonymous users.
  • If you enable page caching, the entire HTML of each page will be stored in the database. This significantly reduces the amount of queries needed.
  • This automatically means that blocks will also get cached, disregarded their own cache settings.
  • If Varnish is configured, this will also enable varnish caching
  • The page cache max-age will be used (see below) for each page.
  • You can check the “X-Drupal-Cache” HTTP header to check if this cache is HIT.

Block caching:

  • If you enable block caching, without enabling page caching, the block cache settings will be used (for anonymous and authenticated).
  • The defaults for most blocks is “don’t cache” because that is the default for blocks who don’t have their cache settings specifically declared.
  • You can use block_cache_alter module to set this for each block.
  • When it’s block created by Views, you can set the cache settings for a block in Views.

Minimum cache lifetime:

  • This is the amount of time before the page cache is cleared.
  • Page caches are cleared on each cron run (system_cron).
  • Be warned: incorrect settings of your cron and this setting might kill your website performance. See also this issue.

Expiration of cached pages:

  • This only applies for external caching mechanisms, for example your browser cache or Varnish.
  • It sets the Cache-Control max-age value in the HTTP-HEADERS.
  • This setting only takes effect when page caching is turned on.

Swapping Column Values in MySQL

UPDATE swap_test SET state_id=district_id, district_id=@temp WHERE (@temp:=state_id) IS NOT NULL;

Above query is using temporary variable to swap values of column values and It is working properly. Although there is second query also available which is perfect way to do this and will work for NOT NULL and NULL both values.

UPDATE swap_test SET state_id=(@temp:=state_id), state_id = district_id, district_id = @temp;

Above query is perfect query to swap two column values with each other in Db table. I am sure there will be lots of other ways to do this and if you know any other better way then let us know in comments