marvix
1
Hi,
I have this action in article controller:
public function actionList($cid){
$PZ = Yii::app()->params['defaultPageSize'];
$dataProvider=new CActiveDataProvider('Article', array('criteria'=>array(
'condition'=>'status=1 AND sticky=0 AND cid='.$cid,
'order'=>'created ASC',
),
'pagination' => array('pageSize' => $PZ, )
)
);
$this->render('list',array(
'dataProvider'=>$dataProvider,
));
}
How I can can this action in the theme to show the result ?
THX
outrage
(Site Sense Web)
2
Ganerally your theme is set in config/main.php like this:
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'name' => 'Your App Name',
'theme' => 'yourTheme',
...
You can also set the theme in your controller like this:
public function actionList($cid){
Yii::app()->theme = 'yourTheme';
...
marvix
3
I do not want to change the action theme, I need to list articles in the index page based on the category… such as:
<div class=cat1>
<?php Article::List('90');
</div>
<div class=cat2>
<?php Article::List('91');
</div>
<div class=cat3>
<?php Article::List('92');
</div>
marvix
4
Anyone?
I need to create block design, a block will hold 5 record based on category if.
Hi,
You can add the following code directly into your themes view file ( main.php )
Yii::app()->runController('article/List/cid/'.$yourid); //Dynamically call the category id.
Use render partial at your action List…
marvix
6
it worked for me, but its render the whole theme again !
I found the solution … in theme index :
$dataProvider=Article::getBlockData(101,6);
$data = $dataProvider->getData();
//Get category name
$Category = Category::model()->findByAttributes(array('id'=>101));
echo '<div class="category-name"><h4>'.$Category->name.'</h4></div>';
foreach($data as $i => $item){
//for clean result without HTML
Yii::app()->controller->renderPartial('_articleBlock',array('index' => $i, 'data' => $item, 'widget' => $this));
}
Thats great marvix,
If we decided MVC structure - you may not use your $dataProvider … and some querying strings …at the view file…
anyway it works fine… CHEERS… MARVIX.