yii-starter-kit / yii2-starter-kit

Yii2 Starter Kit
http://yii2-starter-kit.terentev.net
Other
1.42k stars 648 forks source link

Custom name view in common/config/base.php #713

Closed exploradatos closed 4 years ago

exploradatos commented 5 years ago

I'm trying to make name customized the base.php so that it can be changed, using the table tbl_key_storage_item , in backend use the function Yii::$app->keyStorage->get (), but in common I can't use that function, you can give me some idea how to get the name of the table tbl_key_storage_item

image

XzAeRo commented 4 years ago

You can change the app name using: Yii::$app->name = Yii::$app->keyStorage->get('key_app_name');. Preferably, this should be done before an action is executed, during the bootstrap process, or with the [beforeAction()](https://www.yiiframework.com/doc/api/2.0/yii-base-controller#beforeAction()-detail) method override inside your controller(s).

But, I would suggest to not do this. You'd be better off doing the changes where you want to show this text. I'm guessing you want to show this as the page title or in the menu. For the menu text, you should go to frontend/view/layout/base.php, and change the brandLabel attribute of the Navbar with Yii::$app->keyStorage->get('key_app_name') instead of Yii::$app->name.

For the site/index, you should change the $this->title value the same way I did with the Navbar label.

You should do this change in every place you want to override the "app name".

Also, I want to suggest you change the base name to something more meaningful to you.

exploradatos commented 4 years ago

excellent, consider the second recommendation.