How To Display Controller Action Into Theme?


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, )







How I can can this action in the theme to show the result ?


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';


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 class=cat2>

<?php Article::List('91');


<div class=cat3>

<?php Article::List('92');



I need to create block design, a block will hold 5 record based on category if.


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…

it worked for me, but its render the whole theme again !

I found the solution … in theme index :


                    $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.