To pass variable to login view I use:
$this->render('login', array('model' => $model));
But I also need acces this variable in template part footer.php:
I try this:
$this->render('footer', array('model' => $model));
But when in footer.php I try acces variable I get error "undefined variable"
What is wrong ?
You can use controller class to pass variables in view template, for example
Controller :
SomeController extends Controller {
    
    public function actionIndex() {
          $var1 = 'abc';
          $var2 = '123';
           $this->render('view', 
                           array('var1' => $var1,
                                 'var2' => $var2,
                                ));
    }
}
In view template file you can access these 2 variables ( $var1 & $var2) with its name :
echo $var1; 
echo $var2 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With