So I can use the Smarty plugin html_options
within a template like this:
{html_options options=$arr }
But what I want to do is call the function behind this plugin (smarty_function_html_options
) directly from PHP.
I'm sur开发者_JAVA百科e this must be possible, has anyone got any ideas on how to achieve this?
First, find the PHP file containing html_options
in the Smarty install. Then, include this function from your code. Finally, call the appropriate method in your PHP code.
There's no "official" Smarty way to do this, at least, none that I know of. I just double-checked the documentation and didn't see anything. But since Smarty is itself really just a program written in pure PHP, you shouldn't have problems with the above.
Note that if you have to do this, your code is "wrong" in conformance to the templating-system model: the idea of a templating system is to separate presentation from data. This means that if you have intense code which needs to generate raw HTML, you're doing it wrong.
精彩评论