<style type="text/css"> <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --> </style> Custom Templates
If you create custom vBulletin based files that utilize custom created templates within your forum installation, there are a few tricks to get them to work with vBulletin 4. Prior to vBulletin 4, you were able to use the following code to get vBulletin to evaluate the custom template for your script.
eval('print_output("' . fetch_template('myCustomTemplate') . '");');
With vBulletin 4, the same thing can be accomplished with the following two lines of code.
$templater = vB_Template::create('myCustomTemplate');
print_output($templater->render());
This code will now allow you to reference vBulletin 4 functionality to use your custom template within your custom vBulletin PHP file.
Example
Imagine that yourcustom vBulletin PHP script simply outputs the words "Hello there" and you want that text to appear within your own custom vBulletin template. Your file would have the following somewhere within the code.
$myScript_variable = "Hello there";
Within your custom template (called myCustomTemplate as an example), you would reference this variable as follows.
{vb:raw myScript_variable}
Back within your script, you can make a call to force your custom template to be evaluated. This would be accomplished using the previously example.
$templater = vB_Template::create('myCustomTemplate');
print_output($templater->render());
Using custom templates within your own vBulletin 4 based files
Collapse
X
Collapse
Related Topics
Collapse
-
by donnyazI have installed VB5 on two different servers and I have notice that when I Create New Custom Modules it does not allow me to Edit Rename or Delete the Custom Module.1 Photo
-
Channel: Support Issues & Questions
-
-
Hi I am having a problem with adding a custom module. This is a new forum that I have set up on our site. www.zcorum.com/forums. I receive a database error when I try to add a custom module. Steps to...
-
Channel: Support Issues & Questions
-
-
by adkaushGood day,
Whenever I update my vBulletin version, after all is done, shows the news in the admin area. The first one is always: Out-of-Date Custom Templates Found.
So I click...-
Channel: Support Issues & Questions
-
the php code
<?php
global $vbulletin;
// Include Globals
require_once('./global.php');
$bestphoto =$vbulletin->db->query_first("SELECT * FROM vb_ratemyphoto_photos WHERE approved=1 AND hidden=0
AND rating>0 ORDER BY rating DESC, votes DESC LIMIT 1");
$besttitle = htmlspecialchars_uni($bestphoto["title"]);
$bestphotoname = $bestphoto["logo"];
$bestvotes = $bestphoto["votes"];
$bestrating = $bestphoto["rating"];
$templater = vB_Template::create('block-photo');
$templater->register('besttitle', $besttitle);
$templater->register('bestphotoname', $bestphotoname);
$templater->register('bestvotes', $bestvotes);
$templater->register('bestrating', $bestrating);
$templater->register('bestuserid', $bestphoto[userid]);
$templater->register('bestusername', $bestphoto[username]);
$templater->register('catid', $catid);
print_output($templater->render());
?>
the template :
please where is the error