The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Is this possible? (fieldX values in Thread Information)
I have a custom profile field where users must choose upon registration.
For example, lets say this profile field is called " favorite fruit" and options are; Apple Melon Grape Banana Now How do I get my "thread information" box to display users viewing forums as this; There are currently 6 users browsing this thread. Apple:1 Melon:2 Grape:0 Banana:3 |
#2
|
|||
|
|||
Here's one way you might be able to do it: You would need to turn on "Show Users Browsing Thread" in the adminCP options, then create a plugin using hook showthread_loggedinuser and code like this:
Code:
$viewing_users[] = $loggedin['userid']; Then you need to do a query, in another plugin using hook showthread_complete: Code:
$viewing_users[] = $vbulletin->userinfo['userid']; $field = 'fieldX'; // change X to your actual field # $results = $vbulletin->db->query_read_slave("SELECT $field, count(*) AS num FROM " . TABLE_PREFIX . "userfield WHERE userid IN (" . implode(',', $viewing_users) . ") GROUP BY $field"); while ($row = $vbulletin->db->fetch_array($results)) { $fruit_viewing[$row[$field]] = $row['num']; } // If you don't want to actually display the "users browsing", you could uncomment this: // $show['activeusers'] = false; vB_Template::preRegister('SHOWTHREAD', array('fruit_viewing' => $fruit_viewing)); Then in showthread where you want it to appear, something like: Code:
<vb:each from="fruit_viewing" key="fruit" value="num"> {vb:raw fruit}: {vb:raw num} </vb:each> BTW, I haven't actually tried this. |
#3
|
|||
|
|||
Let me try it and I ll get back to you in a bit
--------------- Added [DATE]1345809644[/DATE] at [TIME]1345809644[/TIME] --------------- This is way too advanced for me. I went to add new plugin and chose "showthread_loggedinuser and put; $viewing_users[] = $loggedin['userid']; in the PHP code Saved it. Then if I did all that right, I m not too sure what you mean by "Then you need to do a query, in another plugin using hook showthread_complete:" Quote:
|
#4
|
|||
|
|||
I was just talking about what the code is doing. You just have to create another plugin like you did for the first one. Make sure you check the "Yes" radio button to enable your plugins.
|
#5
|
|||
|
|||
Code:
<vb:each from="fruit_viewing" key="fruit" value="num"> {vb:raw fruit}: {vb:raw num} </vb:each> It didnt work.. |
#6
|
|||
|
|||
Yeah, I was assuming you'd edit the variable names to something that made more sense.
I did forget one line: at the end of the second plugin, you need to register the variable to the template, like: Code:
vB_Template::preRegister('SHOWTHREAD', array('fruit_viewing' => $fruit_viewing)); |
#7
|
|||
|
|||
I created both hooks and added the line you provided at the end of second hook
changed the fieldX to Field 6 which is where the actual custom field is. i edited the showthread template with the necessary code for the mod to show. still no luck |
#8
|
|||
|
|||
Hmm...did you remember to turn on "Show Users Browsing Thread"?
If it doesn't work I might have to see your exact code (which you can PM if you'd rather). |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|