Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2012, 06:47 PM
achoo254's Avatar
achoo254 achoo254 is offline
 
Join Date: Mar 2012
Location: Vietnam
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to use is_member_of in template postbit

I tried code in template postbit_legacy:

Code:
<vb:if condition="is_member_of($post, 5,6,7)">code here</vb:if>
It's ok, but i try:

Code:
<vb:if condition="is_member_of($post, $vboptions['select_groupid'])">
...don't work, plz help me!

p/s: i tried
Code:
is_member_of($bbuserinfo,....)
or
Code:
is_member_of($post['usergroupid'],....)
...nothing.
Reply With Quote
  #2  
Old 12-15-2012, 06:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is $vboptions['select_groupid'] a string with comma separated group ids? Then maybe this:

Code:
<vb:if condition="is_member_of($post, explode(',', $vboptions['select_groupid']))">
Reply With Quote
  #3  
Old 12-16-2012, 12:04 AM
achoo254's Avatar
achoo254 achoo254 is offline
 
Join Date: Mar 2012
Location: Vietnam
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i tried but errror
Attached Images
File Type: png Untitled.png (28.8 KB, 0 views)
Reply With Quote
  #4  
Old 12-16-2012, 02:18 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, right. My bad. Like the message says, you're not allowed to use that function in a template condition. I think you'll need to create a plugin to do it. Maybe use hook location postbit_display_complete and use the $show[] variable, with code like:

Code:
$show['some_unique_name'] = is_member_of($post, explode(',', $vbulletin->options['select_groupid']));

and then in the template

Code:
<vb:if condition="$show['some_unique_name']">code here</vb:if>

(of course you'd pick something else for 'some_unique_name').
Reply With Quote
  #5  
Old 12-16-2012, 07:11 AM
achoo254's Avatar
achoo254 achoo254 is offline
 
Join Date: Mar 2012
Location: Vietnam
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried but dont work, this is my plugin:

Code:
	<plugin active="1" executionorder="5">
			<title>Demo</title> 
			<hookname>postbit_display_complete</hookname>
			<phpcode><![CDATA[global $vbulletin;
					$show['hidehack'] = is_member_of($post, explode(',', $vbulletin->options['select_groupid']));
		]]></phpcode>
		</plugin>
and my template postbit_legacy:

Code:
<vb:if condition="$show['hidehack']">code here</vb:if>
Reply With Quote
  #6  
Old 12-16-2012, 08:24 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I tried this plugin code:

Code:
global $vbulletin;
$vbulletin->options['select_groupid'] = "5, 6, 7";
$show['hidehack'] = is_member_of($post, explode(',', $vbulletin->options['select_groupid']));
(I added the line to set the option), then I added this in postbit legacy:

Code:
<vb:if condition="$show['hidehack']">Hidehack<vb:else />No</vb:if>

and that seems to work. So maybe you should try to see what your option string it set to. Maybe temporarily put $vboptions[select_groupid] in the template and see what's displayed?
Reply With Quote
  #7  
Old 12-16-2012, 11:55 AM
achoo254's Avatar
achoo254 achoo254 is offline
 
Join Date: Mar 2012
Location: Vietnam
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

done , thank you so much!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:37 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04216 seconds
  • Memory Usage 2,240KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (11)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (1)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete