PDA

View Full Version : Not outputting top buyers?


RuneCentre
07-06-2013, 01:24 AM
I've wanted to have a custom bit of PHP on my custom template for a while now, and just decided to look up the plugin feature for vBulletin. I've wrote a small bit of PHP, and set it to hook to global_start. It is activated.

Plugin objective: Load a custom PHP page I have that displays the top 10 buyers.
Plugin code:


$ch = curl_init('topbuyers.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$topbuyers = curl_exec($ch);
curl_close($ch);


What I have included in my custom template:


{vb:raw topbuyers}


I'm really new to vBulletin. First time using, sorry if I'm making a basic mistake somewhere.

If necessary, here's the custom PHP file topbuyers.php: http://paste2.org/gmBKetZ9

kh99
07-06-2013, 01:09 PM
If topbuyers.php is in your forum directory, you could just include it instead of using curl, like:
ob_start();
include('topbuyers.php');
$topbuyers = ob_get_contents();
ob_end_clean();


I looked at the link to topbuyers.php, and if that's the entire file I don't understand how it would work since it seems to depend on a pre-existing $database variable.

In any case, you also need to register your variable to the template, like this:
vB_Template::preRegister('template_name', array('topbuyers' => $topbuyers));

RuneCentre
07-06-2013, 07:24 PM
If topbuyers.php is in your forum directory, you could just include it instead of using curl, like:
ob_start();
include('topbuyers.php');
$topbuyers = ob_get_contents();
ob_end_clean();


I looked at the link to topbuyers.php, and if that's the entire file I don't understand how it would work since it seems to depend on a pre-existing $database variable.

In any case, you also need to register your variable to the template, like this:
vB_Template::preRegister('template_name', array('topbuyers' => $topbuyers));

The $database variable is already created on vBulletin startup.

This seems to have worked. Didn't know about registering the variables. ;)

Thank you! Very much appreciated. :)