vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Not outputting top buyers? (https://vborg.vbsupport.ru/showthread.php?t=299845)

RuneCentre 07-06-2013 12:24 AM

Not outputting top buyers?
 
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:

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:

Code:

{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 12:09 PM

If topbuyers.php is in your forum directory, you could just include it instead of using curl, like:
Code:

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:
Code:

vB_Template::preRegister('template_name', array('topbuyers' => $topbuyers));

RuneCentre 07-06-2013 06:24 PM

Quote:

Originally Posted by kh99 (Post 2432373)
If topbuyers.php is in your forum directory, you could just include it instead of using curl, like:
Code:

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:
Code:

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. :)


All times are GMT. The time now is 05:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01622 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete