MyBB Community Forums

Full Version: Using templates (I think)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

LOVE MyBB awsome board! (Kissing butt) Big Grin

OK..

I am wanting to add a template to MyBB so I can reference it in code like the search function (example of this below)

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
	<td>$search</td>
</tr>
<tr>
	<td>$latestthreads</td>
</tr>
</table>

I had downloaded the sidebox mod (really cleaver) but what i did not like was having to add raw HTML to the index template to add my own box, so I created a template called cws_login, but i cannot get it to appear.

Any help?

site in question is:

http://www.subzerobadass.com/MyBB

Thanks in advance!

(I suck at php, but Ill whoop yer butt in ASP Toungue )

Bod.

Latest Index Template, nope doesnt work LOL

Quote:<html>
<head>
<title>$settings[bbname]</title>
$headerinclude
<script language=JavaScript>

<!-- Begin
function clearfieldu(){
if (document.login.USERNAME.value == "USERNAME")
document.login.USERNAME.value = "";
}
function clearfieldp(){
if (document.login.PASSWORD.value == "PASSWORD")
document.login.PASSWORD.value = "";
}

function clearfield(){
document.login.PASSWORD.value = "";
document.login.USERNAME.value = "";
}
// End --></script>
</head>
<body>
$header$nars_report <table width="100%" cellspacing="$theme[borderwidth]">
<tr>
<td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink <a href="$settings[bburl]/search.php"> $lang->toplinks_search</a> | <a href="$settings[bburl]/memberlist.php">$lang->toplinks_memberlist</a> | <a href="$settings[bburl]/calendar.php">$lang->toplinks_calendar</a> | <a href="$settings[bburl]/misc.php?action=help">$lang->toplinks_help</a></td>
</tr>
</table><br />
<!-- side boxes -->
<table width="100%" border="0">
<tr>
<td width="20%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<?php
ob_start();
$templatelist = "cws_login";
require "./global.php";
eval("$cws_login= "".$templates->get("cws_login")."";");
outputpage($cws_login);
ob_get_clean();
?>
</td>
</tr>
</table>
</TD>
<td width="60%" valign="top">$forums </td>
<td width="20%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>$search</td>
</tr>
<tr>
<td>$latestthreads</td>
</tr>
</table>
<!-- end body here -->
<br />

</td>

</tr>
</table>

<table border="0" cellspacing="$theme[borderwidth]" cellpadding="$theme[tablespace]" class="tborder">
<thead>
<tr>
<td class="thead">
<div class="expcolimage"><a href="javascript:expandCollapse('boardstats');"><img src="$theme[imgdir]/collapse$collapsedimg[boardstats].gif" id="boardstats_collapseimg" border="0" alt="[-]" /></a></div>
<div><strong>$lang->boardstats</strong></div>
</td>
</tr>
</thead>
<tbody style="$collapsed[boardstats_e]" id="boardstats_e">
$whosonline
$birthdays
$forumstats
</tbody>
</table>
<br />
<table border="0" cellspacing="$theme[borderwidth]" cellpadding="$theme[tablespace]" class="tborder">
<tr>
<td class="trow1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" align="left">
<table cellspacing="0" cellpadding="2" border="0">
<tr><td><img src="$theme[imgdir]/on.gif" alt="$lang->new_posts" /></td><td class="trow"><span class="smalltext">$lang->new_posts</span></td></tr>
<tr><td><img src="$theme[imgdir]/off.gif" alt="$lang->no_new_posts" /></td><td class="trow"><span class="smalltext">$lang->no_new_posts</span></td></tr>
<tr><td><img src="$theme[imgdir]/offlock.gif" alt="$lang->forum_locked" /></td><td class="trow"><span class="smalltext">$lang->forum_locked</span></td></tr>
</table>
</td>
<td valign="top" align="right">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><td valign="top" align="right">
<span class="smalltext">$logoutlink <a href="$settings[bburl]/search.php"> $lang->toplinks_search</a> | <a href="$settings[bburl]/memberlist.php">$lang->toplinks_memberlist</a> | <a href="$settings[bburl]/calendar.php">$lang->toplinks_calendar</a> | <a href="$settings[bburl]/misc.php?action=help">$lang->toplinks_help</a><a href="misc.php?action=markread">$lang->markread</a> | <a href="showteam.php">$lang->forumteam</a> | <a href="stats.php">$lang->forumstats</a></span>
</td></tr>
$loginform
</table>
</td></tr>
</table>
</td></tr>
</table>
$footer
</body>
</html>
You cannot use PHP Code in templates. You have to integrate your code into the file index.php.
Michael83 Wrote:You cannot use PHP Code in templates. You have to integrate your code into the file index.php.

Can you explaine the mechanics behind $Serarch, and $Footer and the other variables as they seem to work.

Where do they get populated and how, where are they defined and how? If I can understand that I can simulate it.

Thanks

Bod.
heloo there

1st of all. read this

sec, using what above u will be able to use ur html along to ur php. all for the sake of a new mybb page.

the variables are those set in the php file, then you then you use them in the html file.

for example if
$me = "bob" ; was the variable in ur php file , u will use

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

to specify in which template this will appear.

many regards
Only variables are evaluated in the template, but PHP isn't.