Answer the question
In order to leave comments, you need to log in
How to create an object in Smarty?
Greetings, tell me how to create an object in the Smarty template?
Calls the usual function: {$func = func()}
But the object does not want to be created: {$object = new object()}
I need to get the questionnaire data in php in the template, it looks like this:
How can I write something like this in the Smarty template?
I made a small crutch in the form of a static method in the User class that returns this object directly$ank = new User($id);
static function getObject($id_user){
return new User($id_user);
}
{$ank = User::getObject($id)}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question