You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now I am trying to simply convert the layouts/main.php file to a smarty template. For that I need access to the current yii\web\View object which is given from the extension as $this-smarty-variable.
I've validated that the smarty $this variable was the same as the view-object through var_dump()-ing and comparing both.
Problem
According to the smarty3 docs I should be able to call a method on the $this-object from smarty templates like this: {var_dump($this->head())}.
Applying the above script in a template just always returns NULL which let me guess that no method call had happen.
Question
How can I call a method from an object which is given to smarty from PHP ?
Define variable for use in smarty: $template->assign('app', \Yii::$app);
Call method on variable in smarty template: {$app->getSession();}
What am I doing wrong ?
(my current smarty layout: pastebin)
If this is no issue to Yii2-Smarty
I'm sorry if this doesn't affect Yii2-Smarty at all but I cant figure out what/why it is not working since this code should work according to Yii2-Smarty and Smarty itself.
I've also asked this question on stackoverflow though nobody has yet answered.
The text was updated successfully, but these errors were encountered:
Okey, but then how do I include the assets from my project in the layout/main.tpl ?
Thought it were done through the yii\web\View::head() method but now I can't find it.
I set up Yii2 with smarty extension.
Now I am trying to simply convert the
layouts/main.php
file to a smarty template. For that I need access to the currentyii\web\View
object which is given from the extension as$this
-smarty-variable.I've validated that the smarty
$this
variable was the same as the view-object throughvar_dump()
-ing and comparing both.Problem
According to the smarty3 docs I should be able to call a method on the
$this
-object from smarty templates like this:{var_dump($this->head())}
.Applying the above script in a template just always returns
NULL
which let me guess that no method call had happen.Question
How can I call a method from an object which is given to smarty from PHP ?
$template->assign('app', \Yii::$app);
{$app->getSession();}
What am I doing wrong ?
(my current smarty layout: pastebin)
If this is no issue to Yii2-Smarty
I'm sorry if this doesn't affect Yii2-Smarty at all but I cant figure out what/why it is not working since this code should work according to Yii2-Smarty and Smarty itself.
I've also asked this question on stackoverflow though nobody has yet answered.
The text was updated successfully, but these errors were encountered: