Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2008, 04:35 PM
Guest210212002
Guest
 
Posts: n/a
Default On/off or yes/no conditional help, please.

I'm trying to set a simple conditional to allow my members to enable/disable a sidebar based on usergroup permissions.

I have a CPF (field18), Single-Selection Radio Buttons, with the options being "Yes" and "No".

In the user's profile options page, is an option: "Display the sidebar? (o) Yes ( ) No".

If the YES button is checked, I want a conditional to display the respective code. From what I can tell by hunting around vb.com, this should work:

<if condition="$post[field18] == 'Yes'">

But it doesn't. :\

What would the proper yes/no (or on/off) conditional syntax be?

Thanks!
Reply With Quote
  #2  
Old 10-08-2008, 04:44 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template are you using that condition in? I think that particular one - $post[field18] - is only available on the showthread page (and, I think it has to do with the poster, not the viewer, and you want the viewer, yes?). Have you tried $vbulletin->userinfo[field18] ?
Reply With Quote
  #3  
Old 10-08-2008, 04:46 PM
Guest210212002
Guest
 
Posts: n/a
Default

That first part would certainly explain a lot, this is driving me nuts.

So what you're saying is:

<if condition="$userinfo[field18] == 'Yes'">

Correct?

/me goes off to try that
Reply With Quote
  #4  
Old 10-08-2008, 04:47 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The values are returned as 1 and 2, it's a number that is returned, not the text.
HTML Code:
</fieldset><fieldset class="fieldset">
	<legend>test</legend>
	<table cellpadding="0" cellspacing="3" border="0" width="100%">
	<tr>
		<td>test</td>
	</tr>
	<tr>

	<td>
		<table cellpadding="2" cellspacing="0" border="0">
		<tr><td valign="top"><label for="rb_cpf_field10_1"><input type="radio" name="userfield[field10]" value="1" id="rb_cpf_field10_1" checked="checked" />yes</label></td></tr><tr><td valign="top"><label for="rb_cpf_field10_2"><input type="radio" name="userfield[field10]" value="2" id="rb_cpf_field10_2"  />no</label></td></tr>
		</table>
		<input type="hidden" name="userfield[field10_set]" value="1" />
	</td>
	</tr>
	

</table>
</fieldset>
look at the source output on edit profile.
Reply With Quote
  #5  
Old 10-08-2008, 04:48 PM
Guest210212002
Guest
 
Posts: n/a
Default

This is what I tried, which didn't do it. I'm doing it on Forumhome:

Code:
<if condition="THIS_SCRIPT == 'index'"> 
<if condition="$userinfo[field18] == 'Yes'">
Reply With Quote
  #6  
Old 10-08-2008, 04:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chris-777 View Post
That first part would certainly explain a lot, this is driving me nuts.

So what you're saying is:

<if condition="$userinfo[field18] == 'Yes'>

Correct?

[high]* Chris-777 goes off to try that[/high]
In my navbar template, I actually use:
HTML Code:
<if condition="$vbulletin->userinfo[field13] <> 'Yes'">
stuff for when it isn't set to Yes
</if>
Reply With Quote
  #7  
Old 10-08-2008, 04:49 PM
Guest210212002
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by noppid View Post
The values are returned as 1 and 2, it's a number that is returned, not the text.
Also doesn't work:

Code:
<if condition="THIS_SCRIPT == 'index'"> 
<if condition="$userinfo[field18] == '1'">
The first part is correct (eg: that alone displays my code), so I think Lynne's on target with the thinking that I need a global conditional, or at least one that works on the index.

--------------- Added [DATE]1223488271[/DATE] at [TIME]1223488271[/TIME] ---------------

Quote:
Originally Posted by Lynne View Post
In my navbar template, I actually use:
HTML Code:
<if condition="$vbulletin->userinfo[field13] <> 'Yes'">
stuff for when it isn't set to Yes
</if>
If there was a way I could fedex you a cake right now, I would. You are absolutely AWESOME Lynne, that works - thank you VERY much as usual!

--------------- Added [DATE]1223488339[/DATE] at [TIME]1223488339[/TIME] ---------------

While I'm at it (though I should probably start a new thread) - how would I go about setting usergroup permissions on my shiny new on/off CPF? The idea here is that contributers can turn something on/off, whilst regular registered users cannot.
Reply With Quote
  #8  
Old 10-08-2008, 04:57 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need a hook after the userinfo is sorted out, yes.

Ok, it's passed from the form as 1 and 2 and stored for comparison in the field as the text, so go with that when comparing.

Secondly. until you go to the profile page and click yes, the field will be blank. eg, the comparison will always fail.
Reply With Quote
  #9  
Old 10-08-2008, 05:02 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chris-777 View Post
If there was a way I could fedex you a cake right now, I would. You are absolutely AWESOME Lynne, that works - thank you VERY much as usual!
Cheesecakes are a particular favorite of mine - no fruit on top, please. Just saying....
Quote:
Originally Posted by Chris-777 View Post
While I'm at it (though I should probably start a new thread) - how would I go about setting usergroup permissions on my shiny new on/off CPF? The idea here is that contributers can turn something on/off, whilst regular registered users cannot.
As far as I know, you cannot put permissions on the option in the UserCP. But, what you may be able to do is in the 'text' for the setting, say it's a premium feature. That way, they can set it to whatever they want, but it shouldn't have an effect if you set a conditional with it like:

HTML Code:
<if condition="$vbulletin->userinfo[field18] == 'Yes' AND is_member_of($bbuserinfo,5,6)">
stuff for users who said Yes in field 18 and are members of usergroup 5 or 6
</if>
(I use that condition in the same template.... makes me wonder if you can use $bbuerinfo instead of $vbulletin->userinfo... I'll have to try that later.)
Reply With Quote
  #10  
Old 10-08-2008, 05:03 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
(I use that condition in the same template.... makes me wonder if you can use $bbuerinfo instead of $vbulletin->userinfo... I'll have to try that later.)
That'll work. Good going.
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:26 PM.


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.04783 seconds
  • Memory Usage 2,254KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (4)bbcode_html
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (6)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_imicons
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete