yii, extension to use for image thumbnail generation : http://www.yiiframework.com/extension/justintimeimageresizer/ And this extension requires this extension : http://www.yiiframework.com/extension/image/
Month: January 2012
YII, display model errors
Yii, display model errors : print_r($model->getErrors());
YII, get current page url
YII, get current page URL Yii::app()->request->requestUri
YII, get name of the called controller action
YII, get name of the called controller action: <?php print CController::getAction()->id ;?>
yii, form, create drop down with values from a model
yii, form, create drop down and populate it with values from any model : Use code below in the view file inside the form: <?php echo $form->dropDownList($model,’item_type_id’, CHtml::listData(ItemType::model()->findAll(), ‘id’, ‘type’), array(’empty’=>’select Type’)); ?>
yii, handling image uploads
In Model file function rules() : <?phparray(‘product_image_1, product_image_2, product_image_3’, ‘file’, ‘types’=>’jpg, gif, png’, ‘allowEmpty’=>true),?> In View file set form like this : <div class=”form”><?php $form=$this->beginWidget(‘CActiveForm’, array( ‘id’=>’products-form’, ‘enableAjaxValidation’=>false, ‘htmlOptions’=>array(‘enctype’ => ‘multipart/form-data’))); ?> <p class=”note”>Fields with <span class=”required”>*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class=”row”> <?php echo $form->labelEx($model,’product_name’); ?> <?php echo $form->textField($model,’product_name’,array(‘size’=>60,’maxlength’=>255)); ?> <?php echo… Continue reading yii, handling image uploads
YII, my sample model for search with relataionship
A model file for yii which has search fucntion which searches using relation ship: <?php/** * This is the model class for table “sf_category_slider”. * * The followings are the available columns in table ‘sf_category_slider’: * @property integer $rec_id * @property integer $cat_id * @property string $brand_id * @property string $slider_image * @property string $slider_link… Continue reading YII, my sample model for search with relataionship
mysql, import sql file from command line
Method 1: A quick way to duplicate MySQL databases is to do the following: Step 1: Dump the database either through PHPMyAdmin’s export form or through mysqldump (as I mentioned above). Note (usually, it’s mysqldump <database-name> -h<hostname> -u<username> -p<password> if you ommit the -h switch it will default to “localhost”). After you enter the command… Continue reading mysql, import sql file from command line
Yii, Ccaptcha. Captcha image doesnt show
Yii Ccaptcha Captcha refers to the imagery device ment to capture bots attempting to fill out your forms for automatic spam submission. It auto generates images with codes that users have to input to submit a form to avoid such spam bot issues. The only real forms that would require this device would be forms… Continue reading Yii, Ccaptcha. Captcha image doesnt show
yii, best way to call jquery, js and css files
Yii, Best pratice to include jquery, js and css files : <?php Yii::app()->clientScript->registerCoreScript(‘jquery’); ?><?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.’/css/style.css’);?><?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.’/js/star_rating.js’);?>