1

Topic: Processing PHP code in templates

This isn't much of a modification, but I figured I'd post it anyhow just in case someone else has the same problem.

I'm using a fairly complex template to wrap my site's interface around the forum, but my site's navigation relies on dynamic content, and PHP code in punBB's template files isn't interpreted properly when the tpl file is parsed. 

If you want to put PHP code in your main.tpl, edit your footer.php and look for this on the last line:

exit($tpl_main);

and change it to:

eval(" ?>".$tpl_main."<?php ");
exit();

Note that if you use this modification, you may want to rename your main.tpl to something like main.tpl.php and edit your header.php to parse the renamed template file to avoid having anyone snoop on your PHP code.

Hope that helps someone. smile  Great work on punBB so far, Kennel!  I'm looking forward to playing with v1.1!

- Talis

Re: Processing PHP code in templates

Ah, that was a small and nice hack :) I'm planning on adding the ability to include PHP files in the templates. I probably won't allow "direct" execution of PHP code though.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: Processing PHP code in templates

Hi Rickard.  Q - would this mod allow the execution of a random banner PHP script?

Thanks - Danny

Re: Processing PHP code in templates

Yes. Just put whatever PHP code you want executed in the templates. Don't forget <?php and ?>.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Processing PHP code in templates

Thanks for the reply!