MyBB Community Forums

Full Version: Template system coding question...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I always ask coding questions here- maybe there should be a forum for non-mybb help (hint hint).

I have a template system which uses a template class. It uses extract() to get assigned variables to an instance of that class, includes a file (the template, cached from db) and replaces vars expressed as <?php echo $whatever ?>

For instance:

$articles = new Template("template.tpl.php");
$articles->addVar("whatever","this is a string");
$articles->init();

but what's a cleaner way of doing this instead of <?php ?> within a template?

I'm just asking for the principle, and maybe 2 or 3 lines of code if that'll help you explain. Any way is fine, including a mycode approach [var]whatever[/var] or like mybb does {$whatever} (prefer the mycode approach, but not by much).

Anyway thanks Big Grin

Also I have looked in the mybb source code (haha lol it's how Learn Big Grin) but couldn't find anything.

Thanks for the time and for reading this long winded post with loads of extra unnecessary information Smile