View Full Version : [VB4] Need help with variables
HolySell
01-04-2012, 10:53 PM
Hey vBulletin.org-Community
I have a problem with my variables :(
I want to "echo" a variable called "gfxpoints"(numeric) in my template "memberinfo_block_ministats", the variable "gfxpoints" should read out with a mysql_query from table user, my question, where I must register the variable gfxpoints that this code in the "memberinfo_block_ministats" works ?
<dl class="stats">
<dt>GFX-Points</dt>
<dd>{vb:raw gfxpoints}</dd>
</dl>
i have tried to register the variable "gfxpoints" in the member.php but it won?t work :(
Try creating a plugin using hook member_execute_start. And you're using vB_Template::preRegister, right?
Edit: oops - the :p in vB_Template::preRegister was changed to a smilie. I meant that you should be using vB_Template::preRegister().
HolySell
01-05-2012, 11:05 AM
ok I try it ;)
--------------- Added 1325765878 at 1325765878 ---------------
member_execute_start I dont?t find the hook :o what I do wrong ?
--------------- Added 1325766285 at 1325766285 ---------------
sry I have found it yay :D
HolySell
01-05-2012, 11:57 AM
ok, it don?t work :(
this is my code in the "memberinfo_block_ministats".
<dl class="stats">
<dt>GFX-Points</dt>
<dd>{vb:raw gfxpoints}</dd>
</dl>
and This I have placed in the member.php on line 140+141
($hook = vBulletinHook::fetch_hook('member_execute_start')) ? eval($hook) : false;
$templater->register('gfxpoints', $gfxpoints);
an this is the php-plugin:
Addon: vBulletin
Hook: member_execute_start
Title: gfxpoints
"Reihenfolge": 5
$usrid = $vbulletin->userinfo['userid'];
$gfxpquery = $db->query_read("SELECT gfxpoints FROM user WHERE userid = '".$usrid."'")or die(mysql_error());
$gfxpoints = mysql_result($gfxpquery,0);
but I can?t see the reuslt :(
OK - this line:
($hook = vBulletinHook::fetch_hook('member_execute_start')) ? eval($hook) : false;
is the place where the plugin code gets executed (if hook location member_execute_start is selected). So you don't need to edit member.php (at least to do what you're trying to do here), you can just put the code in the plugin. Also, you need to use vB_Template::preRegister() because at the point that the plugin code is run, you don't have $templater set yet.
So, take that code out of member.php and try this as your plugin code:
$usrid = $vbulletin->userinfo['userid'];
$gfxpquery = $db->query_read("SELECT gfxpoints FROM user WHERE userid = '".$usrid."'")or die(mysql_error());
$gfxpoints = mysql_result($gfxpquery,0);
vB_Template::preRegister('memberinfo_block_minista ts', array('gfxpoints' => $gfxpoints));
HolySell
01-05-2012, 12:17 PM
thaaaaanks !!! :D I wanna marry you !!! :DDD ;D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.