closerwalk
(Closerwalk)
October 13, 2011, 6:02am
1
Ok here we go, below is my detail view and I have the filename stored in the database and I am trying to link to the file. but the code below produces the url with the proper directory but not the filename.
ie it currently shows
http://myurl.us/cmms/images/
and it should be
http://myurl.us/cmms/images/101 Class.doc
How do I fix?
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'asset_no',
'asset_priority_id',
'asset_status_id',
'asset_category',
'asset_location_id',
'serial_no',
'purchase_start',
'warranty_start_date',
'warranty_end_date',
'cost',
'contract_id',
'comments',
'filename',
array('label'=>'Filename',
'type'=>'raw',
'value'=>CHtml::link(CHtml::encode($model->filename), Yii::app()->baseUrl . '/images/'.$model->filename->filename)),
'company_id',
),
)); ?>
closerwalk
(Closerwalk)
October 13, 2011, 6:11pm
2
Ok here we go, below is my detail view and I have the filename stored in the database and I am trying to link to the file. but the code below produces the url with the proper directory but not the filename.
ie it currently shows
http://myurl.us/cmms/images/
and it should be
http://myurl.us/cmms/images/101 Class.doc
How do I fix?
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'asset_no',
'asset_priority_id',
'asset_status_id',
'asset_category',
'asset_location_id',
'serial_no',
'purchase_start',
'warranty_start_date',
'warranty_end_date',
'cost',
'contract_id',
'comments',
'filename',
array('label'=>'Filename',
'type'=>'raw',
'value'=>CHtml::link(CHtml::encode($model->filename), Yii::app()->baseUrl . '/images/'.$model->filename->filename)),
'company_id',
),
)); ?>
Anyone know how to do this?
closerwalk
(Closerwalk)
October 13, 2011, 6:45pm
3
For anyone needing the answer to this here it is:
the key was:
Declaring the path before the attaching the filename in the link.
<?php $path =Yii::app()->baseUrl.'/images/'; ?>
array('label'=>'Filename',
'type'=>'raw',
'value'=>CHtml::link(CHtml::encode($model->filename), $path .$model->filename)),
'company_id',
<h1>View Assets #<?php echo $model->id; ?></h1>
<?php $path =Yii::app()->baseUrl.'/images/'; ?>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'asset_no',
'asset_priority_id',
'asset_status_id',
'asset_category',
'asset_location_id',
'serial_no',
'purchase_start',
'warranty_start_date',
'warranty_end_date',
'cost',
'contract_id',
'comments',
'filename',
array('label'=>'Filename',
'type'=>'raw',
'value'=>CHtml::link(CHtml::encode($model->filename), $path .$model->filename)),
'company_id',
),
)); ?>