View Full Version : Do you think my random code for adsense/gif-banners will work in a vbulletin template

09-20-2005, 12:43 PM
I want to randomly display my adsense script and a banner or two. Could I insert something like this into my header template:

$number=mt_rand(1, 2);
if ($number==1)
include "http://www.volconvo.com/adsense.txt";
include "http://www.volconvo.com/banners.txt";

With those .txt files full of their respective codes...

Or would you do something else?

The Doc
09-20-2005, 02:56 PM
the content of templates is usually not included and thus php-code won't be parsed. (get_contents is used instead).
So you'll need to put this somewhere else.

09-20-2005, 03:56 PM

What type of language would I have to use to actually be able to place this in vbulletin? javascript?

09-20-2005, 04:23 PM
The problem with this an the vbulletin scripting (depending on your version), is that vB 3.x will accept limited functions for their templates, due to their 'simplistic' methods. vB templates are called using eval() functions, which will evaluate any php contained within them. 3.x versions will be tricky at best though, I'd personally recommend another routine for this.
Take your global.php file, add what you have, but capture this information into a new variable. You can now use this variable within the actual vBulletin templates. Instead of using include structures, use a file() method instead (file_get_contents, readfile, etc), anything to put it into a string. Name your variable accordingly though, you don't want to overwrite a vbulletin template call.