How to reuse a Block made in the
view1: @app/views/config/index.php
by the
view2. @app/views/profile/index.php
?
- works in view1:
Yii::$app->view->params['menuConfig'] = $this->blocks['menuConfig'];
echo Yii::$app->view->params['menuConfig'];
- did’nt work in view2:
echo Yii::$app->view->params['menuConfig'];
because the Yii::$app->view->params[‘menuConfig’] was empty(checked with var_damp).
- same result by using:
$app->params['menuConfig'];
By the way, the Block shoudn’t be passed through view1->layout(main.php)->view2.
Thanks in advance.
Peng