The bTemplate used in xbtit, is a php class which allow us to separate the code (php) from the html (template), using simple loop and if statements.
When we consider this from the coder point of view it weird (and at the beginning hardest) than having all (php code and html) hardcoded in same file, but as designer/tracker's admin it's a great feature!
You can completely change your site aspect without have to find html within the php code like in older btit, one of the greatest advantage of this, is reducing a lot the possibility of errors (typo or code) and it's much more secure.
As said above, the template system consist (at least) into 2 part:
<br /> <table class="lista" cellpadding="0" cellspacing="0" <tag:block_width /> align="center"> <tr> <td class="block" align="center" height="20px"><b><tag:block_title /></b></td> </tr> <tr> <td width="100%" align="<tag:block_align />" valign="top"> <tag:block_content /> </td> </tr> </table>
You can see it's pure html only here, all variable which will be changed by php code are called ”<tag:var_name />”, then our php code will just need to call the $btemplate→set(“var_name”,$phpvar); to replace the var_name with the $phpvar value.
Then if you need to change the look of the block, you need to change only this template (block.tpl) and css classes.
1.function set_block($block_title,$alignement,$block_content,$width100=true) 2.{ 3. global $STYLEPATH, $TABLE_PREFIX, $language; 4. 5. $blocktpl=new bTemplate(); 6. $blocktpl->set("block_width",($width100?"width=\"100%\"":"")); 7. $blocktpl->set("block_title",$block_title); 8. $blocktpl->set("block_align",$alignement); 9. $blocktpl->set("block_content",$block_content); 10. return $blocktpl->fetch(load_template("block.tpl")); 11. 12.}
Here you don't see, but of course, you'll have to include bTemplate.php (if not already done by xbtit).
line 5: we create a new btemplate's instance
line 6 to line 9: we assign some variable values to some btemplate's tags (if you look at the template's file, you'll find exactly the same <tag:block_* /> as set here.
line 10: tell the class which template to load and then elaborate (change) previous set tags with right values.
It's really harder to explain how to use the template system than to use it… A good start (and test) could be the bTemplate Documentation.
In xbtit distribution, the tpl's files (templates) are present only in xbtit_default's style, why?
Interesting question
xbtit always use xbtit_default/*.tpl unless it find requested tpl into requested style. Ehm, I know, seems to be a crazy explanation, then let us do an example:
the torrent's list display have some missed columns (compared to btit), then let us suppose you want to keep the default style as is (and I personally recommend to keep it original) and change the aspect of “Frosted”'s one (by adding torrent's size and uploader).
<td align="center" width="30" class="header"><tag:torrent_header_complete /></td>
add:
<td align="center" width="30" class="header"><tag:torrent_header_uploader /></td> <td align="center" width="30" class="header"><tag:torrent_header_size /></td>
and after:
<td align="center" width="30" class="lista" style="text-align: center;"><tag:torrents[].complete /></td>
add:
<td align="center" width="30" class="header"><tag:torrents[].uploader /></td> <td align="center" width="30" class="header"><tag:torrents[].size /></td>
In this specific case we don't have to change php code, because in default code the same columns as in btit are filled.
You can see here to type of bTemplate's tag:
You find more info on tag's type on bTemplate's Documentation.
If you login to your site and look at the torrent's list page, you'll see that using xbtit_default is not the same as using Frosted
I hope to be clear enough, but if you have questions, ask on forums