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
                if(isset($_GET['Customer']))
                        $model->attributes=$_GET['Customer'];
                
                Yii::app()->user->setState('exportModel',$model); //this can be any other storage

                $this->render('admin',array(
                        'model'=>$model,
                ));
        }

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
                
                if(Yii::app()->user->getState('exportModel'))
                      $model=Yii::app()->user->getState('exportModel');

                $dataProvider = $model->search(false);
                
                // csv header
                echo    Customer::model()->getAttributeLabel("Id").",". 
                                Customer::model()->getAttributeLabel("Country_Id").",". 
                                Customer::model()->getAttributeLabel("Gender_Id").",".
                                Customer::model()->getAttributeLabel("First_Name").",".
                                Customer::model()->getAttributeLabel("Last_Name").
                                " \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";
                }
                
                exit; 
        }

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: http://www.acquia.com/blog/5-key-features-be-excited-about-drupal-8#sthash.MJcY2eqn.dpuf

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');
 
$value->getSelect()
    ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.customer_id', array('firstname' => 'value'))
    ->where('ce1.attribute_id='.$fn->getAttributeId()) 
    ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.customer_id', array('lastname' => 'value'))
    ->where('ce2.attribute_id='.$ln->getAttributeId()) 
    ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"));
 
print_r($$value->getData());

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"?>
<config>
<modules>
<Love_Home>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Page/>
</depends>
</Love_Home>
</modules>
</config>



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

app/code/local/Love/Home/etc/config.xml

Insert the following code into the file:


<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<page>
<layouts>
<love_home module="page" translate="label">
<label>Home Layout</label>
<template>page/home.phtml</template>
<layout_handle>page_home_layout</layout_handle>
</love_home>
</layouts>
</page>
</global>
</config>


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

app/design/frontend/default/YOUR_THEME/page/home.phtml

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.