View Full Version : Members can see how many are subscribed to their thread
dutchbb
09-19-2012, 03:08 PM
Does this mod exist? If not, someone interested in creating it?
dutchbb
09-29-2012, 12:40 AM
bump
You can do something like this: create a plugin using hook showthread_complete and this code:
if ($thread['postuserid'] == $vbulletin->userinfo['userid'])
{
$res = $vbulletin->db->query_first_slave("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $thread[threadid]");
$subscribed_count = $res['count'];
}
Then edit the SHOWTHREAD template and use $subscribed_count where you want the count to appear, maybe like:
<if condition="$thread[postuserid] == $bbuserinfo[userid]">
$subscribed_count subscribed to this thread
<if>
CAG CheechDogg
09-29-2012, 02:07 PM
@ kh99 - How would you do this for vb4?
lol, I originally posted it for vb4 then noticed the request was posted in the vb3 section. Anyway, here it is for vb4:
if ($thread['postuserid'] == $vbulletin->userinfo['userid'])
{
$res = $vbulletin->db->query_first_slave("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $thread[threadid]");
vB_Template::preRegister('SHOWTHREAD', array('subscribed_count' => $res['count']));
}
<vb:if condition="$thread[postuserid] == $bbuserinfo[userid]">
{vb:raw subscribed_count} subscribed to this thread
</vb:if>
CAG CheechDogg
09-29-2012, 02:14 PM
lol ! Thank you so much kh99, I "did' notice the (Last edited by kh99 : Today at 06:30. Reason: changed for vb3 ) , let me try this out...brb..
--------------- Added 1348932066 at 1348932066 ---------------
Ok, I got the following:
The following error occurred when attempting to evaluate this template:
Invalid Tag Nesting
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
I am trying to add it right below the (Thread Information Block) and the code for that looks like this:
<div id="thread_info" class="thread_info block">
<vb:if condition="$show['activeusers']">
<h4 class="threadinfohead blockhead">{vb:rawphrase thread_information}</h4>
<div id="thread_onlineusers" class="thread_info_block blockbody formcontrols">
<div class="inner_block">
<h5>{vb:rawphrase users_browsing_this_thread}</h5>
<div>
<p>{vb:rawphrase users_currently_browsing_x_y_z, {vb:raw totalonline}, {vb:raw numberregistered}, {vb:raw numberguest}}</p>
<ol class="commalist">
<vb:each from="activeusers" value="row">
<li><a class="username" href="{vb:link member, {vb:raw row}}">{vb:raw row.musername}</a>{vb:raw row.invisiblemark}{vb:raw row.buddymark}{vb:raw row.comma}</li>
</vb:each>
</ol>
</div>
</div>
</div>
</vb:if>
Something missing here?
--------------- Added 1348932537 at 1348932537 ---------------
Ok, I got the code in but nothing will display. I did make sure someone is subscribed to the thread and nothing.
It seems to work for me, like if I add it here (showing only the end of the above code):
</vb:each>
</ol>
</div>
<vb:if condition="$thread[postuserid] == $bbuserinfo[userid]">
{vb:raw subscribed_count} subscribed to this thread
</vb:if>
</div>
</div>
</vb:if>
If you're trying to put it somewhere else you'll have to show us exactly what you're doing.
Ok, I got the code in but nothing will display. I did make sure someone is subscribed to the thread and nothing.
Is it your thread? The <vb:if> makes it so it only displays if you started the thread.
CAG CheechDogg
09-29-2012, 02:33 PM
No, it's not my thread.
So what's the code so it shows on any thread?
--------------- Added 1348932961 at 1348932961 ---------------
Ok, I am trying to add it here......Marked in red....
<!-- / next / previous links -->
</vb:if>
<div id="thread_info" class="thread_info block">
<vb:if condition="$show['activeusers']">
<h4 class="threadinfohead blockhead">{vb:rawphrase thread_information}</h4>
<div id="thread_onlineusers" class="thread_info_block blockbody formcontrols">
<div class="inner_block">
<h5>{vb:rawphrase users_browsing_this_thread}</h5>
<div>
<p>{vb:rawphrase users_currently_browsing_x_y_z, {vb:raw totalonline}, {vb:raw numberregistered}, {vb:raw numberguest}}</p>
<ol class="commalist">
<vb:each from="activeusers" value="row">
<li><a class="username" href="{vb:link member, {vb:raw row}}">{vb:raw row.musername}</a>{vb:raw row.invisiblemark}{vb:raw row.buddymark}{vb:raw row.comma}</li>
</vb:each>
</ol>
</div>
</div>
</div>
{vb:raw subscribed_count} subscribed to this thread
</vb:if>
{vb:raw similarthreads}
{vb:raw template_hook.showthread_after_activeusers}
<vb:if condition="$show['tag_box']">
<h4 class="threadinfohead blockhead">{vb:rawphrase tags_for_this_thread}</h4>
<div id="thread_tags_list" class="thread_info_block blockbody formcontrols">
<div class="inner_block">
<vb:if condition="$show['manage_tag']">
<a id="tag_edit_link" href="threadtag.php?{vb:raw session.sessionurl}t={vb:raw thread.threadid}" class="textcontrol" style="float:{vb:stylevar right}; font-size:11px; margin:10px;">{vb:rawphrase edit_tags}</a>
</vb:if>
<div id='tag_list_cell'>
{vb:raw tag_list}
</div>
<p>
<a href="tags.php{vb:raw session.sessionurl_q}">{vb:rawphrase view_tag_cloud}</a>
</p>
</div>
</div>
</vb:if>
--------------- Added 1348933145 at 1348933145 ---------------
This is what I get:
https://www.cagclan.com/subscribed_thread.jpg
That should work, but I forgot that you'd also need to remove the if from the plugin code, like:
$res = $vbulletin->db->query_first_slave("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $thread[threadid]");
vB_Template::preRegister('SHOWTHREAD', array('subscribed_count' => $res['count']));
CAG CheechDogg
09-29-2012, 02:44 PM
HA! yes it works now.
I am going to bug you with one more question if you don't mind. How would you do it to show exactly who is subscribed to the thread just like who is currently browsing the thread?
You can try this:
$res = $vbulletin->db->query_read_slave("SELECT subscribethread.userid, username, usergroupid, infractiongroupid, displaygroupid FROM " . TABLE_PREFIX . "subscribethread AS subscribethread
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(subscribethread.userid = user.userid)
WHERE threadid = $thread[threadid]");
$subscribed_count = 0;
$subscribers = array();
while ($row = $db->fetch_array($res))
{
$subscribed_count++;
fetch_musername($row);
$row['is_last'] = ($subscribed_count == $db->num_rows($res));
$subscribers[] = $row;
}
vB_Template::preRegister('SHOWTHREAD', array('subscribed_count' => $subscribed_count, 'subscribers' => $subscribers));
and in the SHOWTHREAD template:
</BR>{vb:raw subscribed_count} subscribed to this thread</BR>
<vb:each from="subscribers" value="subscriber">
<a class="username" href="{vb:link member, {vb:raw subscriber}}">{vb:raw subscriber.musername}</a><vb:if condition="!$subscriber[is_last]">, </vb:if>
</vb:each>
And I know it doesn't give you colored user names or show you which ones are logged in or are friends. If you really want any of that I'll have to work on it a little later.
Edit: Well, now it does color the username, which turned out to be pretty easy. I think that matches what's in the other lists in the info, so I probably won't add anything else unless someone really wants it.
CAG CheechDogg
09-29-2012, 03:45 PM
Nice! Ok let me try it....brb...
CAG CheechDogg
09-29-2012, 03:50 PM
Yeep! that works perfect, thanks a lot kh99!
When ever you get to it if you can add the colored names or show you which ones are logged in or are friends, but this is fine.
Once again thanks a lot!
I updated the above so it will display the colored usernames. (There's only one small change to the template code, where subscriber.username is changed to subscriber.musername, so you don't have to copy over the entire template code block if you've made other changes to it).
As I mentioned, I don't think I'll add the other things unless someone really has a strong desire for them (I don't think the other lists in that section have Invisible/logged in/friend marks, do they?)
CAG CheechDogg
09-29-2012, 04:03 PM
Ok, I added the m to subscriber.username and that didn't show any usernames at all just the comman.
The following does have the Invisible/logged in/friend marks
<li><a class="username" href="{vb:link member, {vb:raw row}}">{vb:raw row.musername}</a>{vb:raw row.invisiblemark}{vb:raw row.buddymark}{vb:raw row.comma}</li>
Did you also copy the new plugin code? I did change the plugin code as well, I just wanted to point out the minor change in the template code in case you were making other chnages, so you wouldn't have to start from scratch.
Is that code from one of the other lists? Then I can probably go steal the code for that, but this time it really will be later. :)
CAG CheechDogg
09-29-2012, 04:08 PM
Yes I also did the plugin code as well and just the comma shows up.
Yeah no problem man , you have done more than enough! Once again thanks!
I will recheck the the plugin code though just to make sure
--------------- Added 1348938873 at 1348938873 ---------------
Disregard that kh99 it works now...once again thanks!
this is what I need... but I'm lost... idiots guide please ?
CAG CheechDogg
10-01-2012, 07:16 PM
Johm I am sorry bro, I assumed you would know what to do.
Go and make a new plugin in by going to your vb admin panel and click on Plugins & Products > Add New Plugin
Once in there you will find the fields to complete:
1. Product = vBulletin
2. Hooks Location = showthread_complete
3. Title = Members subscribed to thread (or any tittle you want to give it)
4. Execution Order = leave as is
5. Plugin PHP Code = enter the code here
6. Plugin is Active = yes
Once you do that go to your SHOWTHREAD template and look for the following:
<li><a class="username" href="{vb:link member, {vb:raw row}}">{vb:raw row.musername}</a>{vb:raw row.invisiblemark}{vb:raw row.buddymark}{vb:raw row.comma}</li>
</vb:each>
</ol>
Below that add this:
</BR>{vb:raw subscribed_count} subscribed to this thread</BR>
<vb:each from="subscribers" value="subscriber">
<a class="username" href="{vb:link member, {vb:raw subscriber}}">{vb:raw subscriber.musername}</a><vb:if condition="!$subscriber[is_last]">, </vb:if>
</vb:each>
And that is all buddy.
You sir are a hero.....
everything works :D
--------------- Added 1349177858 at 1349177858 ---------------
One question.....
Is there a way to make this visible to more than one user group?
CAG CheechDogg
10-02-2012, 07:55 PM
Only one usergroup is able to view it? If that is true I did not know that.
--------------- Added 1349211391 at 1349211391 ---------------
I am viewing it as admin and as just a guest and you can see it. Let me know what you see buddy.
Bob_R
03-15-2013, 12:15 AM
Where do you see who is subscribed to what threads? I've installed this but see no lists.
dutchbb
03-15-2013, 12:30 AM
Can someone post the whole thing for vb3 again, because this is al very confusing. Thanks.
Dwarden
03-15-2013, 07:32 PM
would be possible to edit this to show only "counter of subscribers" at forumdisplay (list of threads) ?
for version 4.2.x
e.g. just like Replies / Views counters
Bob_R
03-16-2013, 05:49 PM
Where do you see who is subscribed to what threads? I've installed this but see no lists.
Is there an answer in our future?
Where do you see who is subscribed to what threads? I've installed this but see no lists.
You need to create a new plugin using the posted code, and also edit the SHOWTHREAD template and insert the code where you want the list to appear. If you've done both of those and still aren't seeing anything, first of course make sure you're looking at a thread that you know people have subscribed to, then double check that the plug and template edit are correct.
Bob_R
03-16-2013, 09:29 PM
You need to create a new plugin using the posted code, and also edit the SHOWTHREAD template and insert the code where you want the list to appear. If you've done both of those and still aren't seeing anything, first of course make sure you're looking at a thread that you know people have subscribed to, then double check that the plug and template edit are correct.
I put the code in the SHOWTHREAD as per post #21.
Here's my plugin code
$res = $vbulletin->db->query_read_slave("SELECT subscribethread.userid, username, usergroupid, infractiongroupid, displaygroupid FROM " . TABLE_PREFIX . "subscribethread AS subscribethread
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(subscribethread.userid = user.userid)
WHERE threadid = $thread[threadid]");
$subscribed_count = 0;
$subscribers = array();
while ($row = $db->fetch_array($res))
{
$subscribed_count++;
fetch_musername($row);
$row['is_last'] = ($subscribed_count == $db->num_rows($res));
$subscribers[] = $row;
}
vB_Template::preRegister('SHOWTHREAD', array('subscribed_count' => $subscribed_count, 'subscribers' => $subscribers));
GOT IT!!!!
Thanks!! For your help
Dwarden
03-17-2013, 10:09 PM
bob wanna share screen of the result ?
BlackxRam
04-01-2013, 02:20 AM
How can the "Show Users Who Have Subscribed" instead of just the number of subscribers be added to the VB3 plugin? Will it not work for VB3?
BlackxRam
04-06-2013, 09:52 AM
Anyone know how to make it work and make it public for every one to see?
dutchbb
07-04-2013, 05:44 PM
bump would still like official release
TTayfun
07-22-2018, 02:21 PM
Hello guys, how can i this at forumdisplay page?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.