My Google+ Profile

Tuesday 27 November 2012

6 Steps to Create a Successful Website

Creating website is very important and responsible task. You need to take into account all the main moments to make it user-friendly and informative. We want to share with you stages cover website design and development processes.


Background Information

First of all, you need to know for sure the purpose of your website. Very often people think they defined with a choice when at the last moment generate new idea for new site. There are the main moments to be considered:
  • know the main purpose of your website: service promotion, providing information to visitors, products selling, etc.;
  • define what you are going to gain from the site and what you want to accomplish: your goals (make money, share information);
  • detect the target audience: try to imagine the “ideal” person who will visit your site (age, sex, interests); this will help you when you’ll be choosing content for your site.

 

Make a Plan

This is a second but very important stage. It’s time for writing site map (a list that includes the main topics and sub-topics). Designers and developers select the main tools that will be used for building your site depending on its purpose and target customers.

 

Design Process

Designers of your website are preparing images of layout, interface, etc. and send you possible variants to choose the most suitable one. On this step specialists are guided by the idea of “ideal” visitor. For example, if your website will provide information for women it should have an appropriate template, maybe something in pink colors, feminine, glamour and light; in case if you aim to make something for businesses try minimalist style with classic elements, etc. Don’t forget about company logo to identify it on the site.

 

Development Process

This is a time for implementation of chosen techniques on practice and finally development of the website. Usually everything starts with creation of the Home Page. Developers follow the main navigational structure for the site – the shell for interior. On this stage you still can make and corrections or additional changes.

 

Testing and Delivering Processes

This is very important, but unfortunately often overlooked step. Before launching your website you need to be sure everything works as intended. For this purpose experts make functional, usability and other types of testing, examine the codes to prevent any risks associated with vulnerabilities. Web designers use FTP or CMS to upload files into the website, index it and ensure that site operates correctly and users can visit it through the various browsers.

 

Maintenance

Creation and launching the website is only beginning. Whether you ordered development of the website or made it by yourself you need to update the content frequently, add some information or make corrects. Most of designers will be happy to continue work with your site. If you aim to increase the search engine ranking you better hire SEO-optimizer, copywriter, etc.
So, what useful information you can extract from this article? There are the main 6 steps of website creation. It is not easy to put it on practice, you need to figure out many aspects before starting to provide the project with succeed implementation.

Saturday 24 November 2012

Date validation in Yii

The date validator CDateValidator was added to Yii in release 1.1.7 and provides an easy method to validate that a field contains a date, time or datetime, with the following parameters.

format - option enables you to specify the date format or a list of date formats in an array.

allowEmpty - whether to allow empty or null values

for example:

public function rules()
{
return array(
           // multiple formats specified to allow for 01/02/20012 and 1/02/2012
           array('experience_from, experience_to ', 'date', 'format'=>array('dd/MM/yyyy','d/MM/yyyy'), 'allowEmpty'=>true),
           array('created_dt, last_updated, ', 'date', 'format'=>'yyyy-MM-dd HH:mm:ss', 'allowEmpty'=>false),
  );
}


So now we can be sure that the user has input valid date formats – what about date ranges.

If we wanted to check that the experience_to is greater than the experience_from we could perhaps use the compare validator for date ranges as follows:

  array('experience_to','compare','compareAttribute'=>'experience_from','operator'=>'>', 'allowEmpty'=>true,'message'=>'{attribute} must be greater than "{compareValue}".')


So, wouldn’t life be nice and easy if this code worked …. but it doesn’t!

The date comparison validator uses datetimestamps.  It does not convert textual dates into timestamps.  Therefore the date in the format “dd/mm/yyyy” of 16/01/2012 is greater than 10/02/2012.

It looks as though we will still need to build a custom function to convert these dates to datetimestamps first and then do the comparison test.

So here is date function to do that validation.

        public function dateCompare($attribute,$params) {

            if (empty($params['compareAttribute']) || empty($params['operator']))
               $this->addError($attribute, 'Invalid Parameters to dateCompare');

            $compareTo=$this->$params['compareAttribute'];

            if($params['allowEmpty'] && (empty($this->$attribute) || empty($compareTo)))
        return;

            //set default format if not specified
            $format=(!empty($params['format']))? $params['format'] : 'dd/MM/yyyy';
            //default operator to >
            $compare=(!empty($params['operator'])? $params['operator'] : ">";

            $start=CDateTimeParser::parse($this->$attribute,$format);
            $end=CDateTimeParser::parse($compareTo,$format);
            //a little php trick - safe than eval and easier than a big switch statement
            if (version_compare($start,$end,$compare)) {
                    return;
            } else {
                    $this->addError($attribute, "start date is not $compare end date");
            }
        }

and then we can change the validation rules as follows:

{
return array(
           array('experience_from, experience_to ', 'date', 'format'=>array('dd/MM/yyyy','d/MM/yyyy'), 'allowEmpty'=>true),
           array('created_dt, last_updated, ', 'date', 'format'=>'yyyy-MM-dd HH:mm:ss', 'allowEmpty'=>false),
           array('experience_to','dateCompare','compareAttribute'=>experience_from','operator'=>'>', 'allowEmpty'=>true),
  );
}

Thanks.

Export to excel CGridview filtered/shorted record in Yii.



Recently, i have find an issue to export CGridview filtered record in excel in my Yii application. I have searching out lot many thigs but i did not get exact solution which i want. In all reference tutorial, i can export CGridview record without filtered or shorted record.

Finally i got one solution to export filtered CGridview record to excel using session and toexcel extension of Yii. You can see in following search method, I have stored filtered record in session variable and return it. So whenever i will search any record details it will store in session variable. And later, i will use that session variable to export action.

    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('nationality_id',$this->nationality_id);
        $criteria->compare('nationality_name',$this->nationality_name,true);
        $criteria->compare('nationality_organization_id',$this->nationality_organization_id);
        $criteria->compare('nationality_created_by',$this->nationality_created_by);
        $criteria->compare('nationality_created_date',$this->nationality_created_date,true);

        $nationality_data = new CActiveDataProvider(get_class($this), array(
            'criteria'=>$criteria,
        ));
       
        $_SESSION['nationality_records'] = $nationality_data;
        return $nationality_data;
    }

Here, Assign CActiveDataProvider data to session variable.

    public function actionNationalityExportToExcel()
    {
        $this->toExcel($_SESSION['nationality_records'],
        array(
            //'nationality_id::SN',
            'nationality_name',
            'Rel_user.user_organization_email_id',
            'Rel_org.organization_name',
       
        ),
        'Nationality',
        array(
            'creator' => 'RudraSoftech',
        ),
        'Excel2007'
        );
    }

Note : Also go throw the toexcel extension and put require class file in extension folder directory.

Using this extension you can export data in excel in multiple excel version format like 2005 and 2007.

Static Radio Button List in Yii

Generate RadioButtonList

The following code:

echo CHtml::RadioButtonList('id', '', array('student'=>'Student','employee'=>'Employee'));

will generate:

<input value="student" id="id_0" type="radio" name="id">
<label for="id_0">Student</label>
<br>
<input value="employee" id="id_1" type="radio" name="id">
<label for="id_1">Employee</label>

Other tricks:

Display them inline without '<br>' separator:


echo CHtml::RadioButtonList('id', '', array('student'=>'Student','employee'=>'Employee'), 
array('labelOptions'=>array('style'=>'display:inline'), separator'=>''));