Log in

View Full Version : How to to force the templates to parse a php script and then call it like '$script'


Coldhands
10-26-2005, 07:51 PM
This is what I have in my phpinclude_start file in the template section of the admin cp:

// Example of how to include a seperate file:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
$numrows = 19;
if ($numrows > 1)
{$numrows = $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum = mt_rand(0, $numrows);
}
else $bannum = 0;
$banneraddress="/home/actuary/public_html/banners/banner".$bannum.".html";
$bannerurl = file_get_contents($banneraddress);



and when I want one of my 19 banners to show up I used to type:

$bannerurl

and one of my banners would show up, but now I get nothing. Is there a change in vB 3.5 with the syntax that I'm missing or is there a better way to server up random html code in the header that I don't know about?

Paul M
10-26-2005, 09:57 PM
vb 3.5 does not use the phpinclude template, you need to move that code to a plugin, using the global_start hook.

btw, the logic of that code is a bit strange, you set numrows=19, and then immediately test if its > 1, which obviously it will be ..........

Coldhands
11-02-2005, 02:53 PM
Right on Paul. That worked like a charm, thanks.

What I did in Laymen's terms

plugin system >> add new plugin

added title (bannerurl) and call it in navbar using $bannerurl

and used hook location 'global_start' under 'vBulletin; General"

My banner ads rotate just fine now. Thanks.