here the images residing in the uploads folder in the application folder itself
where as the image name residing with the reg_no(primary key) so the $data->reg_no is appended with the image attribute
note that the value field should be defined in single quotes (' ') only. in single quotes double quotes exists. dont define in double quotes
array(
'header' => 'Image',
'name' => 'image',
'value' => '($data->image === "NIL" ? $data->image :CHtml::link($data->image,Yii: :app()->baseUrl."/uploads/".$ data->reg_no."_".$data->image, array("target"=>"_blank")))',
'type'=>'raw',
),
and display them in CGRIDVIEW:
Here the application name is dev_tslr where the images are residing outside of the application names tslrimgs
for example in the same D: the both directories dev_tslr and tslrimgs are existing
so the url Yii::app()->baseUrl gives us the path of dev_tslr since the tslrimgs are outside of this folder
../ is appended so we move back to home folder i.e., outside of application folder and then we are choosing the tslrimgs
if the uploads folder existing in the application itself then we can directly use the path
Yii::app()->baseUrl.'/uploads/ ' can be used
Yii::app()->basePath -- gives the app_dir/protected path.
<?php
// Dialog::message('LOGIN SUCCESS', "Welcome $uname");
$uname=Yii::app()->user->name;
if($uname=='admin') {
$format='{view}{update}{ delete}';
}
else{
$format='{view}{update}';
}
?>
<?php $this->widget('zii.widgets. grid.CGridView', array(
'id'=>'tslrimg-grid',
'dataProvider'=>$model-> search(),
'filter'=>$model,
'columns'=>array(
'id',
'ward',
'block',
// 'image',
array(
'header' => 'Image',
'name' => 'image',
'value' => 'CHtml::link($data->image,Yii: :app()->baseUrl."/../tslrimgs/ ".$data->image,array("target"= >"_blank"))',
'type'=>'raw',
),
'mand_name',
'vill_name',
'tsnofrom',
'tsnoto',
array(
'class'=>'CButtonColumn',
'template'=>$format,
),
),
)); ?>
where as the image name residing with the reg_no(primary key) so the $data->reg_no is appended with the image attribute
note that the value field should be defined in single quotes (' ') only. in single quotes double quotes exists. dont define in double quotes
array(
'header' => 'Image',
'name' => 'image',
'value' => '($data->image === "NIL" ? $data->image :CHtml::link($data->image,Yii:
'type'=>'raw',
),
and display them in CGRIDVIEW:
Here the application name is dev_tslr where the images are residing outside of the application names tslrimgs
for example in the same D: the both directories dev_tslr and tslrimgs are existing
so the url Yii::app()->baseUrl gives us the path of dev_tslr since the tslrimgs are outside of this folder
../ is appended so we move back to home folder i.e., outside of application folder and then we are choosing the tslrimgs
if the uploads folder existing in the application itself then we can directly use the path
Yii::app()->baseUrl.'/uploads/
Yii::app()->basePath -- gives the app_dir/protected path.
<?php
// Dialog::message('LOGIN SUCCESS', "Welcome $uname");
$uname=Yii::app()->user->name;
if($uname=='admin') {
$format='{view}{update}{
}
else{
$format='{view}{update}';
}
?>
<?php $this->widget('zii.widgets.
'id'=>'tslrimg-grid',
'dataProvider'=>$model->
'filter'=>$model,
'columns'=>array(
'id',
'ward',
'block',
// 'image',
array(
'header' => 'Image',
'name' => 'image',
'value' => 'CHtml::link($data->image,Yii:
'type'=>'raw',
),
'mand_name',
'vill_name',
'tsnofrom',
'tsnoto',
array(
'class'=>'CButtonColumn',
'template'=>$format,
),
),
)); ?>
No comments:
Post a Comment