Display Iframe in CGridView inside of Yii 1.1

816 views Asked by At

So the title says it all i want to be able to display an iframe for the you tube video that he has stored in the inside of the database i am doing the following and it is giving

 array(
            'header'=>'Video',
            'name'=>'videoUrl',
            'value'=>'<iframe width="560" height="315" src="<?php echo $model->videoUrl  ?>" frameborder="0" allowfullscreen></iframe>',
            'type'=>'html',
        ),

As type i have tried eveything like raw,html and text but it still gives me an error like this all the time.

Parse error: syntax error, unexpected '<' in C:\Users\Steve\Documents\Drive\Frameworks\yii\framework\base\CComponent.php(612) : eval()'d code on line 1
2

There are 2 answers

1
Ali MasudianPour On BEST ANSWER

You need to change it like below:

'value'=>'CHtml::tag("iframe",array("width"=>"560","height"=>"315","src"=>$model->videoUrl,"frameborder"=>"0","allowfullscreen"=>""),"")'

As everything in value will be passed into PHP's eval() function.

2
raths On

use those ext it will make you easier.

yiitube

jyoutube

just call widget with the youtube video id and size if you wish.