for example i wanna get a certain data/model/etc. from $content so that specific data will be the only thing shown on the page.
for example i wanna get a certain data/model/etc. from $content so that specific data will be the only thing shown on the page.
everything you pass through the render() in your controller should be available in $content and you can access it there. do you have a more specific example you want to achieve?
like a specific field in a table in a model? for example banner_image?
how do you pass the banner_image to the $content?
on my main controller:
public function actionList()
{
require('Banners.php');
$banners = new Banners;
$banner=Banners::model()->findAll();
$this->render('list',array(
'banner'=>$banner
));
}
on the default action page: ‘list’
foreach($banner as $model2):
echo '<img src="' . $model2->banner_image . '" />';
endforeach;
on the main.php layout:
<?php print $content; ?>
actually it already showed but just in the single page where the action takes place. i want this specific object to appear everywhere. . pls help T_T
You can create a widget. Create a file banner.php in components.
class banner extendx CWidget
{
public function run()
{
foreach(Banners::model()->findAll() as $model2)
echo '<img src="' . $model2->banner_image . '" />';
}
}
In your main.php layout you should be able to do:
$this->widget('banner');
<?php print $content; ?>
IT WORKS!!! THANKS A MILLION TIMES!!! [SOLVED]