Yii-User Extension: Problem With View

Hi everyone,

I’m using this extension (http://www.yiiframework.com/extension/yii-user/) to manage users. I’m in trouble, because I cannot change this view: /protected/modules/user/views/user/index.php

Original code with CGridView




$this->widget('zii.widgets.grid.CGridView', array(

	'dataProvider'=>$dataProvider,

	'columns'=>array(

		array(

			'name' => 'username',

			'type'=>'raw',

			'value' => 'CHtml::link(CHtml::encode($data->username),array("user/view","id"=>$data->id))',

		),

		array(

			'name' => 'createtime',

			'value' => 'date("d.m.Y H:i:s",$data->createtime)',

		),

		array(

			'name' => 'lastvisit',

			'value' => '(($data->lastvisit)?date("d.m.Y H:i:s",$data->lastvisit):UserModule::t("Not visited"))',

		),

	),

));



I would to replace it with




$dataProvider->sort->defaultOrder='username ASC';

$this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_userview',

	'ajaxUpdate'=>false

));



I get this error:

[b]PHP warning

require(): Filename cannot be empty [/b]

I’m sure the problem is on


'itemView'=>'_userview'

becouse of the path with subfolders.

Standard path is /protected/views/model_name/view_name. We have, instead, /protected/modules/user/views/user/_userview.php

I’ve tried different ways, like /user/_userview or user/_userview but now I need help!

Anyone knows how to do?

Thanks

I have no information about CListView, but in general you can use this to change the path to views.

var_dump($this->getViewPath()) show me




string 'C:\wamp\www\myproject\protected\modules\user\views\default' (length=57)



So how can I set C:\wamp\www\myproject\protected\modules\user\views\user\mycustomview ?

Thanks

OK i’ve same problem…

This is solution to fix this…

In user/views/user create default folder

and put your item view in here


user/views/user/default/_userview.php

Even if I set absolute path like




$dataProvider->sort->defaultOrder='username ASC';

$this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'C:\wamp\www\myproject\protected\modules\user\views\user\_userview',

	'ajaxUpdate'=>false

));



I get same error:

PHP warning

require(): Filename cannot be empty

C:\wamp\www\yii\framework\web\CBaseController.php(130)

118 if(is_array($data))

119 extract($data,EXTR_PREFIX_SAME,‘data’);

120 else

121 $data=$data;

122 if($return)

123 {

124 ob_start();

125 ob_implicit_flush(false);

126 require($viewFile);

127 return ob_get_clean();

128 }

129 else

130 require($viewFile);

131 }

132

133 /**

134 * Creates a widget and initializes it.

135 * This method first creates the specified widget instance.

136 * It then configures the widget’s properties with the given initial values.

137 * At the end it calls {@link CWidget::init} to initialize the widget.

138 * Starting from version 1.1, if a {@link CWidgetFactory widget factory} is enabled,

139 * this method will use the factory to create the widget, instead.

140 * @param string $className class name (can be in path alias format)

141 * @param array $properties initial property values

142 * @return CWidget the fully initialized widget instance.

Anyone can help me? Thanks

I don’t know if the origin of the problem is this path (I’m assuming this, but I cannot set it correctly).

Other opionions?

Thanks