vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Custom profile field conditionals for check boxes (https://vborg.vbsupport.ru/showthread.php?t=287770)

WorldCraft 09-12-2012 07:33 PM

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?:confused:

Scanu 09-12-2012 07:51 PM

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...

WorldCraft 09-12-2012 11:27 PM

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.

Scanu 09-12-2012 11:33 PM

I'm not sure if i understand you, are you trying to do this

WorldCraft 09-12-2012 11:37 PM

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.

Scanu 09-13-2012 12:00 AM

Yes that's exactly what i figure out about an hour go :D Do you want this conditional to work in a plugin or in a template

WorldCraft 09-13-2012 12:09 AM

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. :(

Scanu 09-13-2012 09:44 AM

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?

WorldCraft 09-14-2012 02:20 AM

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.

Scanu 09-14-2012 10:21 AM

You must redouble the number each time...

e.g. (1,2,4,8,16,32,64 etc..)


All times are GMT. The time now is 10:02 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.01105 seconds
  • Memory Usage 1,748KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete