In my SiteController.php
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
//$this->render('index');
$dataProviderUser=new CActiveDataProvider('User',array(
'pagination'=>array(
'pageSize'=>20,
),
));
$dataProviderDomain = new CActiveDataProvider('Domain');
$this->render('index',array(
'dataProvider1'=>$dataProviderUser,
'dataProvider2'=>$dataProviderDomain
));
}
In my themes/k/views/layout/main.php
<?php
if(!Yii::app()->user->isGuest)
{
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider2,
'itemView'=>'_view',));
?>
This error appears: Undefined variable: dataProvider2
If i do this in my main.php:
<?php
$dataProvider2 = new CActiveDataProvider('Domain');
if(!Yii::app()->user->isGuest)
{
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider2,
'itemView'=>'_view',));
?>
That works fine so far. But if I go to the User Profil:
/user/view/id/5
Property "Domain.username" is not defined.
So in my User _view.php Yii seems to take the Domain Dataprovider.
How do I past those dataProviders to my layout main.php file? The SiteController.php doesn't seem to do that right.
Would be very nice, if someone has an idea here. Thanks in advanced.