PDA

View Full Version : Variable output doesn't work


M4GN3T
08-10-2011, 09:46 PM
Hi guys,

I created a plugin/hook with the following code:

Product: vBulletin
Hook Location: global_start (also tried init_startup)
Subject: XPRank
Execution Order: 5
Plugin PHP code:

$gebruiker_id = 1;
$sql="SELECT `xp` FROM `rank` WHERE `userid` = '".$gebruiker_id."'";
$dataxp=mysql_query($sql)or die(mysql_error());

while($inhoud = mysql_fetch_array($dataxp)) {
$xprank = $inhoud['xp'];
}


In my header template i use the following:
{vb:raw xprank}

Result:
Doesn't work, even not when i create a variable like $phpecho="test echo"; and then use {vbraw: phpecho}. Nothing works. Does anyone has a idea how to fix this?

kh99
08-10-2011, 09:55 PM
You need to register the variable for use in the template. Add this line to your code:

vB_Template::preRegister('header', array('xprank' => $xprank));


Here's an article if you want to read more about it: https://vborg.vbsupport.ru/showthread.php?t=228078

M4GN3T
08-10-2011, 10:04 PM
You need to register the variable for use in the template. Add this line to your code:

vB_Template::preRegister('header', array('xprank' => $xprank));


Here's an article if you want to read more about it: https://vborg.vbsupport.ru/showthread.php?t=228078

Thanks man, i read the article already and even tryed your solution but that also didn't work for me.

If i do echo $xprank; in the plugin, it outputs it above the website, so there is a value in it and the code is right. The variable contains data, the trick now, is to output it. I added your line of code and still had no output whatsoever using this:

{vb:raw xprank}

Normally, i have no problems finding errors and understanding them but this one is driving me crazy for hours because the docs say it should work. I Use vbulletin 4.0.1.

--------------- Added 1313018307 at 1313018307 ---------------

Thanks man, i read the article already and even tryed your solution but that also didn't work for me.

If i do echo $xprank; in the plugin, it outputs it above the website, so there is a value in it and the code is right. The variable contains data, the trick now, is to output it. I added your line of code and still had no output whatsoever using this:

{vb:raw xprank}

Normally, i have no problems finding errors and understanding them but this one is driving me crazy for hours because the docs say it should work. I Use vbulletin 4.0.1.

I think it was a cache problem, because while waiting for your reply it suddenly appeared. Thanks a lot!