PDA

View Full Version : Getting PHP to load in side bar?


WoodiE
10-24-2007, 02:55 PM
I have the following PHP code:


<?php
$image[0]['src'] = '/images/your-ad-here.gif';
$image[0]['link'] = 'http://www.domain.com';
$image[0]['title'] = 'Your Ad Here';
$image[0]['alt'] = 'Your Ad Here';
$image[1]['src'] = '/images/advertisement2.gif';
$image[1]['link'] = 'http://www.domain2.com';
$image[1]['title'] = 'Company';
$image[1]['alt'] = 'Company';

shuffle( $image );
$html = '';
foreach( $image as $arr )
{
$html .= '<a href="' . $arr['link'] . '" title="' . $arr['title'] . '" rel="nofollow"><img src="' . $arr['src'] . '" alt="' . $arr['alt'] . '"></a>';
}

echo $html;

?>


The code works exactly how I want it to in a PHP page or a wordpress page, however I can't get this to work in vBulletin or in a vbulletin side menu.

How would I go about doing this?

ragtek
10-24-2007, 03:18 PM
you put this code into a plugin with hook global_start for example but without echo $html;

then you can put $html into the the template where it should be shown

Opserty
10-24-2007, 03:21 PM
I would use another variable name instead of $html since vB might use that somewhere. (I know they use $HTML in the UserCP so you could get conflicts. Go with something more descriptive but still short. ;)

WoodiE
10-24-2007, 03:25 PM
ragtek,

Worked just like a dream - thanks so much!

--------------- Added 1193243392 at 1193243392 ---------------

Opserty,

I will change the variable as well then!