How to reference Smarty variables inside {php} tags

I gotta’ be honest, I’ve never used the Smarty Template Engine before in my life. I’m currently working on a project to integrate WordPress and JobberBase so they use the same WordPress theme. JobberBase uses Smarty, so I’m getting a crash course.

You can use PHP in the template (.tpl) files and reference the values of the assigned Smarty template variables like this:

  $html_title = $this->_tpl_vars['html_title'];
  $echo $html_title;

I’m sure Smarty users cringe at this sort of thing, being that it adds business logic to the template files. But, this is just the functionality I need to hack the JobberBase templates without mucking around in core JobberBase code.

I found this solution in the Smarty FAQ after hours of Googling.

2 thoughts on “How to reference Smarty variables inside {php} tags

  1. Thanks I needed this. Just because something is written in PHP doesn’t mean it’s business logic, template files can also be written in php 😉 Personally I think smarty is a piece of crap and I would rather use PHP templates, but in my current situation I have to work with it.

Leave a Reply

Your email address will not be published.