filburt1 |
05-10-2003 10:00 PM |
Embed PHP in Templates
This hack lets you embed PHP code in templates. Simply add your code between a <? ( not a <?php) and ?> tag and it will be eval'ed. All variables will be referenced in the global scope.
If you're using my Usergroup Tags in Templates hack then you're going to have an extraordinarily difficult time installing this hack. However the clever hacker can tell what has changed in this version.
You can somewhat use this to do conditionals in templates. Theoretically, this will work:
Code:
template...
<? $myvar = ($condition ? $truevalue : $falsevalue); ?>$myvar
...more template...
Just make sure that the variable to the left of the = and the variable right after the ?> match. Note that the entire <? and ?> tag itself will be stripped from the final template.
This hack also enhances the comments delimiting templates (if that option is turned on) to include the character count and PHP block count of the specified template.
|