MyBB Community Forums

Full Version: Basic question: how to include a custom template into other templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
We need to include a bit of HTML into our templates, So, we made a new templateName inside Global Templates and tried calling it with {$templateName} but it's not showing up. So we tried putting it in Default Templates/ungrouped, still doesn't work.

How is this done?
eval("\$header = \"".$templates->get("header")."\";");
And add after
eval("\$TemplateName = \"".$templates->get("TemplateName")."\";");
Which Php file would that be?
(2012-12-24, 10:10 PM)Monaco Wrote: [ -> ]Which Php file would that be?

This might be similar to an issue I am trying to resolve in another thread. If I'm understanding Jordan right, he means to simply find that first line of coding in whatever file you're trying to call your new template info in, and then simply paste that 2nd line under it without removing or editing the original line he gave. (but I think he means global.php... see my note below)

If I'm understanding this right, it MIGHT also do what I'm trying to figure out. Basically I've been trying to figure out how to "call" different variables that are created in a different template.

Can a more experienced user chime in and let us know if these issues are similar? Will Jordan's resolution above also make it so any variable created in "TemplateName" can now be called by the file in which he pastes that 2nd line of code?

NOTE: On second thought Jordan may have meant to specifically add that line into the global.php file. Upon a quick search I'm not finding that line he mentioned in any other files than global.php. I've noticed a lot of the answers people give still leave new questions, so I'm right there with you buddy. Smile
Oh sorry I had that in my post but then deleted it. The file would be ./global.php.
I tried this. I added the appropriate line in global.php. The template include works in the index template but not in the header template.

In index this works


In header this does not work
<div id="content">

The goal is to create a template and include it into the header template so that it appears everywhere.

Why doesn't this work?
Because you need to add the custom line before the header eval line. If the variable is part of the header then the variable must be defined before the header so that its contents are included.
Yeah that makes sense. Thanks.
Considering that, it would be best to put your custom template evals before the group of them in the global.php file.
Thank you everyone.
Pages: 1 2