诗酒论年华
- 诗酒论年华 2018-04-19 已签到连续签到3天,获得了15个金钱
- 诗酒论年华 2018-04-18 已签到连续签到2天,获得了10个金钱
- 诗酒论年华 2018-04-17 已签到连续签到1天,获得了5个金钱
如果是用户的个人信息,可以用
Yii::$app->user->identity->username;
其它的话,可以通过
params
这个属性://View 文件源码 class View extends Component implements DynamicContentAwareInterface { ... /** * @var mixed custom parameters that are shared among view templates. */ public $params = []; ... }
用法举例
首先需要在视图文件中:
$this->params['model'] = $model; $this->params['example'] = $example; ...
然后在
main.php
布局文件中就可以:$model = $this->params['model']; $example = $this->params['example']; ... print_r($model); //在你需要显示的地方显示 print_r($example); //在你需要显示的地方显示
这样需要在每个视图文件都要写一次了吧?有点麻烦!我是需要从数据库取出数据,然后在布局文件header好footer中显示
- 诗酒论年华 2018-04-12 已签到连续签到3天,获得了15个金钱
- 诗酒论年华 提出了问题backend 登录后,路径怎么不对?