PDA

View Full Version : Making a variable global?


Merriweather
02-27-2007, 10:13 PM
I installed a the VB Image Hosting mod (https://vborg.vbsupport.ru/showthread.php?t=123481) which I love, but have an issue and though it's marked "supported", the author is not replying. I am hoping someone can help.

There's a template modification made to make the number of images the user has uploaded show in the postbit. It works fine in the forums, however, if I post an announcement, that space is left blank, like it can't retrieve the variable to know what to display.

The variable it pulls into the postbit is called $post[vbimghost] and I'm wondering if someone could help direct me as to where to find what that variable is pulling from? I've gone through the files from the product but there's no "$post[vbimghost]" in them, so I'm a little lsot as to where to look.

I'm newer to vB, but not to programming, so a push in the right direction would be helpful.

Reeve of shinra
02-28-2007, 12:22 AM
The $post variable is an array in the core vb functions that queries iirc the user and userfield tables.

Merriweather
02-28-2007, 01:58 AM
Thank you, that got me started. I actually found the code in a postbit for the mod, and it looks like this:

$rec = $vbulletin->db->query_read("
SELECT count(*) mark
FROM ".TABLE_PREFIX."vbimghost
WHERE userid='".$post['userid']."' and imgprivate='0'
");
$row = $vbulletin->db->fetch_array($rec);
$post['vbimghost']=$row['mark'];

I tohught the issue may be because it's querying based on the $post['userid'] and that when I post an announcement, there is no such variable, but that is not the case. $post['userid'] is used in the announcement, so that part is OK.

Now I am stuck. I can only guess that somehow, this plugin isn't being used when the postbit of an announcement is pulled, but I don't know why.

Reeve of shinra
02-28-2007, 02:41 AM
I'm not familiar with the mod but there are other hacks (like the journal and photopost and vbgallery, and maybe a few others) that work in a similiar way, they may have an answer to your issue.

If anything, I think the plug in is using a hook that is only called up for threads, not announcements. You may need to add the code to a new plugin using the correct hook, or changing the hook location to global. The later may have a performance hit on your forums so use with care.

Merriweather
02-28-2007, 03:01 AM
Ah ha! You got me going in the right direction. The hook location was showthread_postbit_create and I changed it to postbit_display_complete and that fixed the issue.

Thank you. :)