PDA

View Full Version : Show icons for specific usergroup (threadstarter) in threadbit?


kpmedia
12-18-2016, 03:51 AM
On the thread listing page (threadbit), in vB3 and vB4, I find the icons to the left of the thread title to be useless. To make that space useful, I'd like to show icons only for threads started by members of certain "priority" usergroups. Their threads get icons, normal members will not.

The easiest way is to wrap this code (which shows one of the icons)
<img src="$stylevar[imgdir_statusicon]/thread$thread[statusicon].gif" id="thread_statusicon_$thread[realthreadid]" alt="<if condition="$show['threadcount']"><phrase 1="$thread[dot_count]" 2="$thread[dot_lastpost]">$vbphrase[have_x_posts_in_thread_last_y]</phrase></if>" border="" />
in an conditional if statement. But that's my dilemma -- what should it be?

I've tried writing several statements, but none have worked, or even come close. All those did was blank out the icon column, and showed nothing.
Example of NOT working:
<vb:if condition="is_member_of($vbulletin->thread[postuserid], 6, 33)">
</vb:if>

I came across this: http://stackoverflow.com/questions/32851477/vbulletin-4-how-do-i-branch-a-conditional-based-on-usergroup#

$vbulletin->userinfo and $bbuserinfo grab the user viewing the page. What you want is to grab the user whose post you are iterating over. If you look at the context of your code, all of the vBulletin variables stem from $memberinfo. That's the current poster, and the variable we want. Try: <vb:if condition="is_member_of($memberinfo, 14)">


That makes sense, however it also does not work. My first test was to show threads started by an admin.

<vb:if condition="is_member_of($memberinfo, 6)">
</vb:if>

What am I missing?


..

MarkFL
12-18-2016, 04:37 AM
You want to use the $thread array instead of the $memberinfo array in the "threadbit" template.

kpmedia
12-18-2016, 04:49 AM
What would the correct conditional/syntax be?

I just tried this, with no success:
<vb:if condition="is_member_of($vbulletin->thread[postuserid], 6, 33)">
</vb:if>
and
<vb:if condition="is_member_of($thread, 6, 33)">
</vb:if>

MarkFL
12-18-2016, 05:40 AM
Try this:

<vb:if condition="is_member_of($thread, array(6, 33))">
</vb:if>


The is_member_of() function expects an array for its second parameter. :)

kpmedia
12-18-2016, 06:17 AM
That doesn't seem to work. The icon column is still blank.

EDIT: This is working (showing something), but also not:

<vb:if condition="is_member_of($thread[postuserid], array(6,33))">

It's showing the icons for some threads, but it's not the right threads.
- all stickies
- started by moderators
- random normal members

At a glance, it appears to be adding the icon for any thread where the priority members have participated -- not just threads that they've started.

Plus stickies.

But I've found threads started by, and later replied to, by the priority group, which are not receiving icons.

Same for threads not replied to by priority, mods or admins -- just normal thread starter + normal repliers -- yet are receiving icons.

I don't get what's going on here. :confused:

EDIT2: If I removed 6 (leaving only 33 in the array), it shows nothing at all again.

..

MarkFL
12-18-2016, 06:30 AM
Do you have the HTML for displaying the image inside the if-then construct?

kpmedia
12-18-2016, 06:40 AM
I edited my above post several times. You may want to re-read it, if I added anything pertient.

<td id="td_threadstatusicon_7670" class="alt1" style="cursor: pointer;">
<a rel="vB::AJAX"></a>
<img id="thread_statusicon_7670" border="" alt="" src="http://www.x.com/forum/styles/hr/statusicon/thread.gif"></img>
</td>

This is the HTML for an icon shown on a thread, but should not. Started by normal member, replied to by same member. No admin (6), no priority (33), no mod, nobody else.

I'm not sure what the HTML is supposed to reveal.

EDIT: This is from vBulletin admin side:

<img src="$stylevar[imgdir_statusicon]/thread$thread[statusicon].gif"
id="thread_statusicon_$thread[realthreadid]"
alt="<if condition="$show['threadcount']">
<phrase 1="$thread[dot_count]"
2="$thread[dot_lastpost]">$vbphrase[have_x_posts_in_thread_last_y]
</phrase></if>" border="" />

..

MarkFL
12-18-2016, 06:54 AM
The second block of code you posted is using vB 3.x syntax. Which version of vB are you using?

kpmedia
12-18-2016, 07:03 AM
I need to do this on both vB3 and vB4 forums. I can change live code on a vB3 install, while the vB4 has the be done on a development server. The conditional statements barely change between 3 and 4.

The vB4 is essentially using the default plain theme.

..

MarkFL
12-18-2016, 07:10 AM
I need to do this on both vB3 and vB4 forums. I can change live code on a vB3 install, while the vB4 has the be done on a development server. The conditional statements barely change between 3 and 4.

The method for using values stored in variables within templates is different. For example...

vB 3.x:

$thread[title]

vB 4.x:

{vb:raw thread.title}

kpmedia
12-18-2016, 07:14 AM
True, that is a bigger difference, if you're not used to seeing both forums.

Well, I'd like to start with the vB3, and mirror it to the vB4, since it makes the development easier for me.

I can even switch the default theme for vB3, if it makes a difference. (Note: Already tried, same behavior.)

..

MarkFL
12-18-2016, 07:33 AM
On my local dev site (vB 4.2.x) when I edit the threadbit template, in the status icon block section to read:

<!-- status icon block -->
<vb:if condition="is_member_of($thread, array(6))">
<a class="threadstatus" rel="vB::AJAX" <vb:if condition="$show['threadcount']">title="{vb:rawphrase have_x_posts_in_thread_last_y, {vb:raw thread.dot_count}, {vb:raw thread.dot_lastpost}}"</vb:if>></a>
</vb:if>


Then in the forum display, I see the following:

https://vborg.vbsupport.ru/attachment.php?attachmentid=155571&stc=1&d=1482053522

The user "Randall Flagg is not a member of usergroup 6, while "MarkFL" is.

kpmedia
12-18-2016, 08:06 AM
I'm just not getting that result on 3 or 4.

And the vB3 conditional should be:
<if condition="is_member_of($thread, array(6))">
Correct?

..

MarkFL
12-18-2016, 08:17 AM
I'm just not getting that result on 3 or 4.

And the vB3 conditional should be:
<if condition="is_member_of($thread, array(6))">
Correct?

Yes, I haven't worked much with vB 3.x, but I believe that's correct. :)

kpmedia
03-28-2017, 08:25 AM
For whatever reason, this just does not work on vB3.

How would I go about creating a plugin to grab the post starter usergroup?
I'm really rusty, but something like:

if ($vbulletin->userinfo['userid']
AND $vbulletin-> stuff
AND $something == 'thread')
{
this is the icon?
}