MyBB Community Forums

Full Version: Create a new custom template and call in other templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can we create and add a new custom template in the themes&templates and call it in other template files?

Example: default "index_boardstats" is called in "index" template as "{$index_boardstats}"

i tried adding like above but failed.
I would also like the answer to this as i was planning on playing around with adding something to ucp
Just create a template with the code you want to display and in the template you want it to appear, call it with {$yourtemplatenamehere}
not working
It's not as simple as that, you need to tell it which template in the PHP files.

For example, in index.php you'll find this:
eval("\$boardstats = \"".$templates->get("index_boardstats")."\";");
Putting a $ infront of a template name and putting { } around it won't make it load that template., it needs the PHP posted above to tell it what that variable actually contains.
Thank you ajs and matt, it worked. Smile

added a line,
eval("\$newtemplatename = \"".$templates->get("newtemplatename")."\";"); 
in index.php
and called that template as {$newtemplatename} in the template i needed. It worked fine.