Yii2-Smarty: Cannot Access Methods of $this-object -


yii2-smarty: cannot access object methods

i set yii2 smarty extension.

now trying convert layouts/main.php file smarty template. need access current yii\web\view object given extension $this-smarty-variable.

i've validated smarty $this variable same view-object through var_dump()-ing , comparing both.

problem

according smarty3 docs should able call method on $this-object smarty templates this: {var_dump($this->head())}.

applying above script in template returns null let me guess no method call had happen.

question

how can call method object given smarty php ?

  1. define variable use in smarty: $template->assign('app', \yii::$app);
  2. call method on variable in smarty template: {$app->getsession();}

what doing wrong ?

(my current smarty layout: pastebin)

applying above script in template returns null let me guess no method call had happen.

the head() method not return if see null correct.

you can call method this:

{$this->head()} 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -