yii - access to subfolders controller and view in YII2 -
hi built controller in folder inside controllers folder tryed access controller , view couldnt error 404 please tell me problem
here details this siteusercontroller in controllers/userzone/ folder
namespace app\controllers\userzone; use yii\web\controller; use app\models\userzone; /** * default controller `dashboard` module */ class siteusercontroller extends controller { /** * renders index view module * @return string */ public function actionindex() { $id = \yii::$app->user->id; $model = userzone::find()->where(['id_zone'=>$id])->with('user')->one(); // $model->joinwith('companiescompany'); return $this->render('siteuser/index',[ 'model'=>$model ]); } } the view file in views/siteuser/index.php directory .
i changed url manager to
'urlmanager' => [ 'enableprettyurl' => true, 'showscriptname' => false, 'rules' => [ 'userzone/<controller:\w+>/<action:\w+>'=>'userzone/<controller>/<action>', ], ],
two things looking code
the first
you have siteusercontroller user uppercase mean routing rules yii2 should use site-user (for each uppercase char should add - in controller action name
return $this->render('site-user/index',[ 'model'=>$model ]); the second
you in siteusercontroller situser in render function redundant .. use
return $this->render(index',[ 'model'=>$model ]);
Comments
Post a Comment