vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need help with "threads starter" template conditional (https://vborg.vbsupport.ru/showthread.php?t=205708)

vbplusme 02-17-2009 08:03 PM

Need help with "threads starter" template conditional
 
In the threadbit, I have this piece of code:

HTML Code:

<span style="cursor:pointer" onclick="window.open('member.php?$session[sessionurl]u=$thread[postuserid]', '_self')">$thread[postusername]</span>
I want to wrap a condtional around it to test if the thread starter is an administrator and add a title to the display.

Can this be done with template conditionals, if so, which one? All the ones I have tried test for the user rather than the thread starter.

I am thinking something like :

<if condition="$threadstarter = usergroupid 5,6">

for example. Does a template conditional exist for this kind of test?

TIA for any suggestions.

Lynne 02-18-2009 12:27 AM

Try:
HTML Code:

<if condition="is_member_of($thread[postuserid],  6)">stuff</if>

vbplusme 02-18-2009 02:34 AM

Thanks Lynne, I tried it and got unexpected results. I thought it worked at first. I expected that only the administrators would be selected but it also select post from one of the registered users who is not an administrator.

If I do an explicit "<if condition="$thread['postuserid'] == 1">" only the administrator posts are correctly selected but what I want is to be able to select the usergroupid to which $thread[postuserid] belongs.

When I changed you example to 2 thinking it would select all the "registered users", it didn't select any even through some do exist.

Any ideas?

Lynne 02-18-2009 02:55 AM

Now that I relook at that condition, I can see it won't work. It needs the usergroupid, not the id of the user. Instead of $thread[postuserid], you can try $thread[groupuserid] or just $thread, but I don't think the usergroupid is ever grabbed. And, if it isn't, then you will have to get it with the help of a plugin you write.

vbplusme 02-18-2009 05:00 AM

That's what I thought just needed to verify it. thanks very much.

Dismounted 02-18-2009 05:52 AM

When you grab the user info, you will want to fetch all the info for the threads all in one query.

vbplusme 02-18-2009 10:00 AM

Thanks, I haven't started on the query yet, are you thinking I need a join? I was thinking that I would try to do a select on user where userid = $thread[postuserid] and grab the usergroupid from there, like
Code:

$getUserGroup= $vbulletin->db->query_read("SELECT usergroupid FROM `user` WHERE `userid`= $thread[postuserid]);
then I will test for what usergroup and assign it to a $is_admin variable for example.

I only have 4 usergroups that I care about so it not that big of a problem. I would wrap the conditional around my display code:

HTML Code:

<if condition="$is_admin">
I got sidetracked with it because I was trying to use user conditions on a variable value test so it either selected all threads or none. So I am thinking that the thread starter is a variable I should be able to test for to find out what group they are in then add a title or image next to the name in the thread display.

I am thinking that the threadbit_display hook, should that be correct?

If you are thinking something different, I'd be glad to hear about it.

thanks, Michael

Lynne 02-18-2009 03:26 PM

Look for the query in forumdisplay that grabs all the threads to display there. Right above the query is hopefully a hook. Use that hook to grab the usergroupid of the thread starter.


All times are GMT. The time now is 03:29 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01804 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete