how to assign an object to smarty templates?
- by keisimone
i created a model object in PHP
class User {
public $title;
public function changeTitle($newTitle){
$this->title = $newTitle;
}
}
How do i expose the property of a User object in smarty just by assigning the object?
I know i can do this
$smarty->assign('title', $user->title);
but my object has something like over 20 plus properties.
Please advise.
EDIT 1
the following didn't work for me.
$smarty->assign('user', $user);
OR
$smarty->register_object('user', $user);
then i try to {$user->title}
nothing came out.
Thank you.