You are using a template tag and then using the PHP code. But the class you are referencing in the template is already destroyed. “$this” is only valid inside a class method or globally within the class. You should not rely on $this being the class pointer to the smarty template class.
If you want to do this in a template (not recommended) do: