Closed polinwei closed 7 years ago
Hi!
You still need to change the routing rules in the module.
https://github.com/Dominus77/yii2-advanced-start/blob/cc48823cef69e04ad4617387fc922a18324df849/modules/main/Bootstrap.php#L35
'main' => 'main/default/index',
In your module:
'' => 'blogs/post/index',
https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/runtime-routing.md
Or you can also forcefully redirect to the desired controller: https://github.com/Dominus77/yii2-advanced-start/blob/master/modules/main/controllers/frontend/DefaultController.php
public function actionIndex()
{
//return $this->render('index');
return $this->redirect(['/blogs/post/index']);
}
While I forcefully redirect to the desired controller. I got error:
View not Found – yii\base\ViewNotFoundException
The view file does not exist: Y:\xampp\htdocs\myweb/modules/main/views/frontend\blog/post/index.php
While I forcefully redirect to the desired controller. I got error:
View not Found – yii\base\ViewNotFoundException
The view file does not exist: Y:\xampp\htdocs\myweb/modules/main/views/frontend\blog/post/index.php
return $this->redirect(['/blogs/post/index']);
Yes!! I need watch more Attentively!! The both of return $this->redirect(['/blogs/post/index']);
and return $this->redirect('/blogs/post/index');
is different.
May I ask you another questions? While I write Yii code using PhpStorm , It always said "view file for index is not found" . And have any smart method to edit or manage The i18n file ? How should I set the environment?
And after fixing
return $this->redirect(['/blogs/post/index']);
all right?
As for setting up the PhpStorm environment, this is a whole topic. Search the Internet, for sure you will find something.
In my case, the environment settings are all by default. The only thing I do is adjust the folders in the project.
And what do you mean by editing and managing i18n?
Yes. It is all right for return $this->redirect(['/blogs/post/index']);
i18n for multi-message files which how to make sure the $category are the same ?
Umm, but for what? When you translate, you specify the category manually. In the translation file, that is, in the array, the original phrase appears as a key, 2 identical keys will cause an error. The IDE tells you that there are 2 identical keys in the array. What else check?
ok . And how to make sure the $message also are the same?
Do not write the same)
ok. understood
And so, there is a php function for finding the same values in the array. But this does not apply to Yii)
Hi Sir:
I changed the parameter:
defaultRoute' => '/blogs/post/index'
infrontend/config/main.php
, But It still point to'main/default/index'
. What do I need to do ?