YII中CDetailView下使用CHtml image()显示图片的正确用法

来源:互联网 发布:喜来健cms系统 编辑:程序博客网 时间:2024/05/01 15:34

YII中CDetailView下使用CHtml image()显示图片的正确用法

在attributes下增加如下代码:

array(
'name'=>'小图预览',
 'value'=>CHtml::image($model->goods_small_pic,'小图',array('width'=>'100px')),  //这里显示图片
 'type'=>'raw',   //这里是原型输出
 ),

 

视图文件:view.php

<?php/* @var $this TblGoodsController *//* @var $model TblGoods */$this->breadcrumbs=array('Tbl Goods'=>array('index'),$model->goods_id,);$this->menu=array(array('label'=>'商品列表', 'url'=>array('index')),array('label'=>'增加商品', 'url'=>array('create')),array('label'=>'修改商品', 'url'=>array('update', 'id'=>$model->goods_id)),array('label'=>'删除商品', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->goods_id),'confirm'=>'Are you sure you want to delete this item?')),array('label'=>'管理商品', 'url'=>array('admin')),);?><h1>查看商品 ID号为:<?php echo $model->goods_id; ?></h1><?php $this->widget('zii.widgets.CDetailView', array('data'=>$model,'attributes'=>array('goods_id','cat_id','goods_sn','goods_name','click_count','brand_id','goods_number','market_price','shop_price','promote_price','promote_start_date','promote_end_date','goods_desc','goods_small_pic',                /**                 *使用CHtml::image()实现图片的查看                 * $model->goods_small_pic:图片的URL地址                 * type='raw':原型输出                 */                array(                'name'=>'小图预览',                'value'=>CHtml::image($model->goods_small_pic,'小图',array('width'=>'100px')),  //这里显示图片                'type'=>'raw',   //这里是原型输出                ),            'goods_big_pic',                            array(                'name'=>'大图预览',                'value'=>CHtml::image($model->goods_big_pic,'大图',array('width'=>'100px')),  //这里显示图片                'type'=>'raw',   //这里是原型输出                ),            'is_sale','is_delete','is_best','is_new','is_hot','is_promote','add_time',            'shops_id',            'goods_color',            'goods_size',),)); ?>


 

0 0
原创粉丝点击