saebaryo, on 12 December 2010 - 11:05 AM, said:
sama bro, ane juga masih baru di Yii

.
setahu saya itu cuma layout aja.
kalo mau lempar2an variable mending di Model, View, Controller terkait.
emang variable seperti apa yg dikehendaki ?
Makasih bro udah balas...

Gini bro, di view aku dah nge-render model Store:
<?php
$this->breadcrumbs=array(
'Stores'=>array('index'),
$model->name,
);
$this->menu=array(
array('label'=>'List Store', 'url'=>array('index')),
array('label'=>'Create Store', 'url'=>array('create')),
array('label'=>'Update Store', 'url'=>array('update', 'id'=>$model->owner_id)),
array('label'=>'Delete Store', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->owner_id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Store', 'url'=>array('admin')),
);
?>
<h1>View Store #<?php echo $model->owner_id; ?></h1>
<?php
global $current_logo;
$current_logo=StoreLogo::model()->findByPk((int)$model->current_logo);
$current_logo=$current_logo->path;
$this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'owner_id',
'current_logo',
'name',
'signature',
'desc',
'reputation',
'created',
'modified',
),
)); ?>
Nah, aku mau nempatin current logo di bar kanan web(sidebar column2.php). Awalnya aku coba aja nge-echo image di sidebar itu, ternyata di column2 $model sudah tidak terbaca lagi, makanya di code awal ada pelemparan variable melalui
$this->menu. Aku coba sisipkan melalui $this->menu, dengan cara menempatkan $current_logo diarray paling akhir $this->menu, tetap tidak bisa. Solusi terakhir seh, aku manfaat kan keyword global (menurut aku seh, design seperti ini jelek. Pasti ada cara lain).
Berikut code di column2.php
<?php
$this->beginContent('//layouts/main'); ?>
<div class="container">
<div class="span-19">
<div id="content">
<?php echo $content; ?>
</div><!-- content -->
</div>
<div class="span-5 last">
<div id="sidebar">
<div id="store-logo">
<?php
global $current_logo;
echo CHtml::image(Html::imageUrl($current_logo));
?>
</div>
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
));
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
'htmlOptions'=>array('class'=>'operations'),
));
$this->endWidget();
?>
</div><!-- sidebar -->
</div>
</div>
<?php $this->endContent();?>
Bagaimana solusinya bro???