View Full Version : Including templates in VBulletin
Sothside40
12-20-2008, 02:24 PM
Hey, I'm currently trying to write a mod (my first) for vBulletin, and from the mods I've read it seems like they've been able to include their templates inside of other templates such as:
<template name="myTemplate" etc="" etc="">
<div>This is what the first template is</div>
</template>
Then from there I go into the style editor, and inside of the footer template I throw in: $myTemplate. The desired result is for the template I defined as "myTemplate" to be shown inside of the footer. Am I mistaken on the functionality of this? And if so, can you please tell me what I've done wrong?
Lynne
12-20-2008, 03:40 PM
You need to eval a template before it can be used. Look in any of the php pages and you will see templates evaled:
eval('print_output("' . fetch_template('tracker_newupload') . '");');
Sothside40
12-20-2008, 08:25 PM
fetch_template() seems to be returning null, no matter what template I use it on.
Lynne
12-20-2008, 09:14 PM
Well, you probably need to include it in the global templates first.
You should take a look at these articles - How to create your own vBulletin-powered page! (uses vB templates) (https://vborg.vbsupport.ru/showthread.php?t=62164) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc. (https://vborg.vbsupport.ru/showthread.php?t=98009)
Sothside40
12-22-2008, 12:49 AM
I've read those articles, and I can't even get the examples working. fetch_template() is still returning absolutely nothing, even with templates that already exist (footer, navbar, etc).
array_push($globaltemplates, 'test');
eval('print_output("' . fetch_template('test') . '");');
Result is a blank page, when it should be displaying a table. (that I have defined and am 100% positive exists in my boards templates)
Lynne
12-22-2008, 02:59 AM
Post your full php page and your full template. That way we can see what you are doing wrong.
Sothside40
12-22-2008, 09:12 AM
Template: test <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat" width="100%">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('my_table')"><img id="collapseimg_my_table" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_my_table].gif" alt="" border="0" /></a>
<div style="text-align: center;">
New Table Title
</div>
</td>
<tbody id="collapseobj_my_table" style="$vbcollapse[collapseobj_my_table]">
</tr>
<tr>
<td class="alt1" width="100%">
<div class="smallfont">
[snip]
</div>
</td>
</tr>
</table>
PHP: plugin hooked to cache_templatesarray_push($globaltemplates, 'test');
eval('print_output("' . fetch_template('test') . '");');
That's all there is to it.
Adam21
12-22-2008, 09:47 AM
Whats your full php page?Is this page gonna be a link in your navbar or?
Sothside40
12-22-2008, 03:07 PM
I'm gathering the boards last.fm group statistics via the API (which are received with no problem) formatting them into HTML, and then placing them on the forum.
This will add a table(for content) between the main boards and navbar. I know currently my example would merely output just a table, but that's easily remedied once I can get my issues resolved.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.