Posts Tagged with yii

Displaying 71-80 of 113 results.
Resolved: Yii get last parameter from current url without GET name getQuery
posted by admin on April 10, 2016
My controller

public function actionVideo()
{
//want to get last url parametr
}


My URL like

...video/12313213123/dubaivideos


I want to get dubaivideosRead more
Wiki: Yii 1.1: videojswiki
posted by admin on April 9, 2016
EVideoJS extends CWidget and implements a base class for the VideoJS player.

EVideoJS extends CWidget and implements a base class for the VideoJS HTML5 Video Player.

Tested with Yii Framework v.1.1.6 and VideoJS 1.3.0.

Support: http://www.yiiframework.com/forum/index.php?/topic/16592-evideojs/

Installation
Extract the videojs folder under protected/extensions.

Usage
The bare minimum configuration needs:
  • video_mp4 URL
  • width
  • height


The code below shows common usage and options defaults.


$this->widget('application.extensions.videojs.EVideoJS', array(
'options' => array(
// Unique identifier, is autogenerated by default, useful for jQuery integrations.
'id' => false,
// Video and poster width in pixels
'width' => 320,
// Video and poster height in pixels
'height' => 240,
// Poster image absolute URL
'poster' => false,
// Absolute URL of the video in MP4 format
'video_mp4' => false,
// Absolute URL of the video in OGV format
'video_ogv' => false,
// Absolute URL of the video in WebM format
'video_webm' => false,
// Use Flash fallback player ?
'flash_fallback' => true,
// Address of custom Flash player to use as fallback
'flash_player' => 'http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf',
// Show controls ?
'controls' => true,
// Preload video content ?
'preload' => true,
// Autostart the playback ?
'autoplay' => false,
// Show VideoJS support link ?
'support' => true,
// Show video download links ?
'download' => true,
),
));


Resources
VideoJS official web site: HTML5 Video Player

Download
videojs.zipRead more
Resolved: Yii 1.1 CGridView Error 500 Trying to get property of non-object
posted by admin on April 8, 2016
I have CGridView with relation

admin.php in Media view

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'media-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'caption',
array(
'name' => 'gallery_id',
'value' => '$data->gallery->name',
'filter' => CHtml::listData(Gallery::model()->findAll(), 'id', 'name'),
),
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>


Gallery.php Model

class Gallery extends CActiveRecord
{
. . .
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::HAS_MANY, 'Media', 'gallery_id'),
);
}
. . .
}


Media.php Model

class Media extends CActiveRecord
{

public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::BELONGS_TO, 'Gallery', 'gallery_id'),
);
}
}


I see this error

Error 500
Trying to get property of non-object


Error in line

'value' => '$data->gallery->name',
Read more
Wiki: Yii 1.1 cgridview filter dropdown with relation table datawiki
posted by admin on April 7, 2016
View: admin.php

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'media-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'caption',
'created',
'updated',
array( 'name' => 'visibility_id',
'value' => '$data->visibility_id',
'filter' => CHtml::listData(Visibility::model()->findall(), 'id', 'name'),
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>


Model: Visibility.php

class Visibility extends CActiveRecord
{
public function tableName()
{
return 'tbl_visibility';
}

public function rules()
{
return array(
//your rules here
);
}

public function relations()
{
return array(
'media' => array(self::HAS_MANY, 'Media', 'visibility_id'),
);
}

public static function model($className=__CLASS__)
{
return parent::model($className);
}
}


Model: Media.php

class Media extends CActiveRecord
{
public function tableName()
{
return 'tbl_media';
}
public function rules()
{
return array(
//your rules
//...

);
}
public function relations()
{
return array(
'visibility' => array(self::BELONGS_TO, 'Visibility', 'visibility_id'),
);
}

public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
Read more
Resolved: Yii 1.1 Errors not working, throw only yii exeption
posted by admin on April 7, 2016
I got this Yii error on my CRUD UPDATE by $id

The requested page does not exist.


Error line

public function loadModel($id)
{
$model=Media::model()->findByPk((int)$id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');//error line
return $model;
}
Read more
Resolved: Yii Dropdown List Empty Value as Default
posted by admin on April 7, 2016

<?php $type_list=CHtml::listData($galleries,'id','name'); ?>
<?php echo $form->dropDownList($model, 'gallery_id', $type_list); ?>


I want to add empty option to SELECT
In output, I want to get

<select name="sel" id="sel">
<option value="0">Choose Gallery</option>
...
</selected>
Read more
Resolved: Yii 1.1 CHtml listData with relation table
posted by admin on April 5, 2016
I have the list of array from my model

CHtml::listData($tags, 'id', 'post_id')


In model

/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'post' => array(self::BELONGS_TO, 'Post', 'post_id'),
);
}


I want to get listData like this

CHtml::listData($tags, 'id', /*here is syntax to get relation name*/)
Read more
Resolved: Yii 1.1 Get last inserted id
posted by admin on April 5, 2016
I want to get my new inserted row id after save

if ($model->save) :
...
//Do something with my new id
...
endif;
Read more
Resolved: Yii 1.1 Check if the row exist do nothing else insert
posted by admin on April 5, 2016
I have multiple insert to my table, and my inserted values must be unique. I want to check , if my row don't exist, then insert my rowRead more
Wiki: Yii 1.1 Model Save problem in MySQL queryor in update actionwiki
posted by admin on April 5, 2016
In my update Action

if($model->save()) :
...
endif;


And I have problem with MySQL save, it is Yii errorRead more