$criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->addNotInCondition('id',array(1)); $criteria->compare('name',$this->name,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, ));
Monday, November 30, 2015
Yii addNotInCondition
Saturday, November 28, 2015
Yii How to Add and Upload an Image using editMe
$this->widget('ext.editMe.widgets.ExtEditMe', array( 'model' => $model, 'attribute' => 'content', 'ckeConfig'=>array('enableTabKeyTools'=>true,'enterMode'=>2), 'filebrowserImageBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/browse.php?type=files', 'filebrowserImageUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files', 'filebrowserBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files', 'filebrowserUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files' )); // Edit configure in kcfinder/conf/config.php 'disabled' => false, 'uploadURL' => "../upload", // Dowbload kcfinder from http://kcfinder.sunhater.com/download
Thursday, November 26, 2015
Yii Redirect to login for unauthorized user
public function accessRules() { return array( array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete','index','view','create','update'), //'users'=>array('admin'), 'expression'=>'$user->isAdmin()', ), array('deny', // deny all users 'users'=>array('*'), 'deniedCallback' => array($this, 'redirecting'), ), ); }
public function redirecting(){ $this->redirect(array('/login')); }
Wednesday, November 25, 2015
yii how to use og meta tag for facebook share
Yii::app()->clientScript->registerMetaTag(Yii::app()->name,null,null,array('property'=>'og:site_name')); Yii::app()->clientScript->registerMetaTag($this->createAbsoluteUrl('video/details',array('id'=>$video->id, 'slug'=>$video->slug)),null,null,array('property'=>'og:url')); Yii::app()->clientScript->registerMetaTag($video->tittle,null,null,array('property'=>'og:title')); Yii::app()->clientScript->registerMetaTag($video->details,null,null,array('property'=>'og:description')); Yii::app()->clientScript->registerMetaTag("movie",null,null,array('property'=>'og:type')); if($video->screensort): $path_image = YiiBase::getPathOfAlias('webroot').'/upload/'.$video->screensort; $cropimg= Yii::app()->easyImage->thumbSrcOf($path_image, array('crop' => array('width' => 270, 'height' => 150))); Yii::app()->clientScript->registerMetaTag($cropimg,null,null,array('property'=>'og:image')); Yii::app()->clientScript->registerMetaTag("270",null,null,array('property'=>'og:image:width')); Yii::app()->clientScript->registerMetaTag("150",null,null,array('property'=>'og:image:height')); endif;
Subscribe to:
Posts (Atom)