Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2012, 07:33 PM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom profile field conditionals for check boxes

Hello. I'm trying to get some conditionals working for a Multiple Selection Checkbox profile field I've set.

I tried the following conditional, but it doesn't work with checbox values:

Code:
<vb:if condition="$bbuserinfo[fieldX] == 'Show Me'">
<script> Do stuff here </script>
</vb:if>
However, it works fine with Radio button values. I am making sure that the fieldX and Field ID's match, and that the option names are matching exactly as well.

Any ideas why it doesn't work with checkboxes?
Reply With Quote
  #2  
Old 09-12-2012, 07:51 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First option
PHP Code:
<vb:if condition="$bbuserinfo[fieldX] & 1">
<
script> Do stuff here </script>
</
vb:if> 
Second option
PHP Code:
<vb:if condition="$bbuserinfo[fieldX] & 2">
<
script> Do stuff here </script>
</
vb:if> 
Third option
PHP Code:
<vb:if condition="$bbuserinfo[fieldX] & 4">
<
script> Do stuff here </script>
</
vb:if> 
4th option
PHP Code:
<vb:if condition="$bbuserinfo[fieldX] & 8">
<
script> Do stuff here </script>
</
vb:if> 
etc...
Reply With Quote
  #3  
Old 09-12-2012, 11:27 PM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, that works nice. The next thing I'm trying to do is that when User A views User B's profile, User A will see the effects as User B has set them. And vice versa.

The checkboxes they can pick create special effects to make their profile page look nicer.

Similar to how $post['fieldX'] will display information in the user's postbit, is there a condition statement or variable that will do this for user profiles?

Sorry if this request sounds confusing.
Reply With Quote
  #4  
Old 09-12-2012, 11:33 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure if i understand you, are you trying to do this
Reply With Quote
  #5  
Old 09-12-2012, 11:37 PM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just re-worded the post. Sorry, I did word that pretty badly.

I'm trying to give my users bit more freedom with how their profiles look. So I've given them a few checkbox choices they can pick to give them some effects with Javascript.

Is there a statement, or variable, that will show the customizations the user chose when others see their profile, similar to the way that $post['fieldX'] will display customized information in the postbit? But in this case, on the member.php page.
Reply With Quote
  #6  
Old 09-13-2012, 12:00 AM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes that's exactly what i figure out about an hour go Do you want this conditional to work in a plugin or in a template
Reply With Quote
  #7  
Old 09-13-2012, 12:09 AM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh nice. Well I was planning to put all of the statements and scripts in the headinclude templates. Could it all be done there, or do you think a plugin would be best?

Edit I found that the method you displayed in the 2nd post is not working for me. It appears to work fine for the first 2 check boxes, but if I pick any further choices it will run the incorrect script, or multiple scripts, as if it's ignoring the condition. Even if I only choose 1 check box. It's weird because it only behaves in that way for box #3 and onwards.
Reply With Quote
  #8  
Old 09-13-2012, 09:44 AM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you show me your code? And i think it's better to do this in a plugin since i understand you just want to add js files to the page, am i right?
Reply With Quote
  #9  
Old 09-14-2012, 02:20 AM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, but the obstacle I'm at is getting conditionals that check if a certain checkbox or checkboxes are selected.

For a quick concept test I put the following in my headinclude template:

Code:
<vb:if condition="$bbuserinfo[field16] & 1">
<script> alert("You chose checkbox 1!") </script>
</vb:if>


<vb:if condition="$bbuserinfo[field16] & 2">
<script> alert("You chose checkbox 2!") </script>
</vb:if>


<vb:if condition="$bbuserinfo[field16] & 3">
<script> alert("You chose checkbox 3!") </script>
</vb:if>


<vb:if condition="$bbuserinfo[field16] & 4">
<script> alert("You chose checkbox 4!") </script>
</vb:if>


<vb:if condition="$bbuserinfo[field16] & 5">
<script> alert("You chose checkbox 5!") </script>
</vb:if>
It doesn't seem to work properly. For example, if I choose checkbox 1, it will display alerts 1, 3, and 5. If I choose checkbox 2, it will display alerts 2, and 3. Checkbox 3 will display alerts 4 and 5. Checkboxes 4 and 5 will not run any script. I'm pretty new at coding so I'm not finding any obvious pattern and they seem to be executing at random.
Reply With Quote
  #10  
Old 09-14-2012, 10:21 AM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You must redouble the number each time...

e.g. (1,2,4,8,16,32,64 etc..)
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 02:29 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.07331 seconds
  • Memory Usage 2,261KB
  • 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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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
  • (10)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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete