Dominus77 / yii2-advanced-start

Yii2 Start Project Advanced Template
https://dominus77.github.io/yii2-advanced-start/
MIT License
23 stars 12 forks source link

How change the frontend default page? #14

Closed polinwei closed 7 years ago

polinwei commented 7 years ago

Hi Sir:

I changed the parameter: defaultRoute' => '/blogs/post/index' in frontend/config/main.php , But It still point to 'main/default/index'. What do I need to do ?

Dominus77 commented 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

Dominus77 commented 7 years ago

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']);
}
polinwei commented 7 years ago

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
polinwei commented 7 years ago

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
Dominus77 commented 7 years ago

return $this->redirect(['/blogs/post/index']);

polinwei commented 7 years ago

Yes!! I need watch more Attentively!! The both of return $this->redirect(['/blogs/post/index']); and return $this->redirect('/blogs/post/index'); is different.

Dominus77 commented 7 years ago

http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#creating-urls

polinwei commented 7 years ago

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?

Dominus77 commented 7 years ago

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?

polinwei commented 7 years ago

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 ?

Dominus77 commented 7 years ago

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?

polinwei commented 7 years ago

ok . And how to make sure the $message also are the same?

Dominus77 commented 7 years ago

Do not write the same)

polinwei commented 7 years ago

ok. understood

Dominus77 commented 7 years ago

And so, there is a php function for finding the same values in the array. But this does not apply to Yii)