MyBB Community Forums

Full Version: Problem with template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've created a page to output a template called "Website". When it outputs this template, inside of the template called "Website", there is a template its supposed to output called "Header2".

It will output the normal "Header" template, but not my custom one, "Header2". Here are some details:

"Website" template:
<html>
<head>
<title>{$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
</body>
</html>

"Header2" template:

<a name="top" id="top"></a>
	<div id="container">
		<div id="header">
			<a name="top" id="top"></a>
	<div id="container">
		<div id="header">

<table border="0" width="100%"><tr><td><script language="Javascript" type="text/javascript" src="http://www.sonicstadium.org/sonicnews/ticker/js/"></script></td></tr></table>
<div class="menu">
<table class="coll" border="1" width="100%" height="5">
<tr><td align="right" class="coll2"><ul>			<li><a href="http://sonicarena.freehostia.com/forum/showthread.php?tid=10">Rules</a></li>  <b>l</b>
<li><a href="{$mybb->settings['bburl']}/search.php">{$lang->toplinks_search}</a></li> <b>l</b>
					 <li><a href="{$mybb->settings['bburl']}/memberlist.php">Member list</a></li> <b>l</b>
					 <li><a href="{$mybb->settings['bburl']}/calendar.php">{$lang->toplinks_calendar}</a></li> <b>l</b>
					 <li><a href="{$mybb->settings['bburl']}/misc.php?action=help">{$lang->toplinks_help}</a></li> <b>l</b>


<li><a href="http://sonicarena.freehostia.com/">Main site</a></li>  <b>l</b>
<li><a href="http://sonicarena.freehostia.com/gallery/index.php">Image gallery</a></li>  
				</ul>
</td></tr></table></div>
	
	<table border="0" width="100%">
<tr><td class="trowx">

<div class="logo"><a href="{$mybb->settings['bburl']}/index.php"><center><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" /></center></a></div></center></tr></td></table>
					<hr class="hidden" />
			<table class="coll" border="1" width="100%">
<tr><td class="coll2">
				{$welcomeblock}
			</td></tr></table>
<center><!-- BEGIN CBOX - http://www.cbox.ws -->
<div align="center" id="cboxdiv">
<iframe frameborder="0" width="90%" height="100" src="http://www.cbox.ws/box/?boxid=733227&amp;boxtag=8504&amp;sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain" style="border:#DBE2ED 1px solid;" id="cboxmain"></iframe><br/>
<iframe frameborder="0" width="90%" height="100" src="http://www.cbox.ws/box/?boxid=733227&amp;boxtag=8504&amp;sec=form" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform" style="border:#DBE2ED 1px solid;border-top:0px" id="cboxform"></iframe>
</div>
<!-- END CBOX --> </center>
		</div>
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
			{$bannedwarning}
			{$bbclosedwarning}
			{$unreadreports}
			<navigation>
			<br class="clear" />



"Header2" has the EXACT same code as my original "Header" template inside of it, but for some reason, it will not show anything. What am I doing wrong?
You need to qualify the var {$header2} with an eval statement in the appropriate core.php for the "Header2" template to be parsed. Wink

You can use either of these, or both for different headers.

eval("\$header2 = \"".$templates->get("header2")."\";");

eval("\$website = \"".$templates->get("website")."\";");

Depending on where you are loading the "new" templates, dictates to what core.php file the eval(s) should be added to.

And note the lowercase website and header2 templates; that's what you will need to name your new templates to.

Wink