vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Profile fields with conditions (https://vborg.vbsupport.ru/showthread.php?t=220853)

ramil86 08-14-2009 09:05 AM

Profile fields with conditions
 
1 Attachment(s)
Hi everyone. I have a question about adding user profile fields with conditions. What i mean by this is that i want
to add 3 user profile fields with the following types 1)Single-selection radio buttons 2)Single selection menu 3)Single-line text box

My goal is to have 2 radio buttons with an Optional Input and add a condition. When the first radio button is selected i want to activate the
second profile field which is "Single-selection menu" and if the second radio button is selected i want to activate the third profile field.

For example i have a single-selection radio buttons called "Status" with 3 options 1) Student 2) Abiturient 3) Enter your choice.
Underneath i have a Single-selection menu called "Univer" with one selection menu and one "Enter your choice.
Belove it there's a Single-line text box called "School".

1) When a user sets his/her status as "student" he/she'll activate the Single-selection menu called "Univer" and will be able to choose one option
while leaving the third menu called "School" inactive. When saved users will have new profile fields displayed under their usernames such as

Status: student
Univer: American University (selected option)

2) When a user sets his/her status as "Abiturient" he/she'll activate the third menu called "School" and deactivate the second menu called "Univer".
When saved users will have two profile fields displayed under their usernames such as

Status: abiturient
School: High school of B.g etc

3) When the third optional input is entered under their username there'll be only the third option


See the attachment for refferance

Attachment 103223

Attachment 103224

Attachment 103225

I already have all indicated fields but i don't know how to achieve that result, please could help me?

Lynne 08-14-2009 02:32 PM

I dont' think you are not going to be able to do that with default vbulletin profile fields. I think you'll have to just write some php code and use some javascript for the input boxes that only show up after x is done.

ramil86 08-14-2009 05:07 PM

Yes i know that i can't do it with default profiles.
I added this code to postbit

PHP Code:

<if condition="$post['fieldX']">
    
University$post[fieldX]
</if> 

where x is my profile field number

What i wonder is how can i use if conditions correctly to achieve that result. Please could you help me, i am really not good at codding. Please i really need it

Lynne 08-14-2009 06:16 PM

You can try something like:
HTML Code:

<if condition="$post['fieldX'] == 'student'">
    University: $post[fieldy]
<else />
  <if condition="$post['fieldX'] == 'abiturient'">
      School: $post[fieldz]
  <else />
    <if condition="$post['fieldy']">
        University: $post[fieldy]
    </if> 
  </if>
</if>

If that doesn't work, please post *exactly* what you've done with the correct field numbers.

ramil86 08-14-2009 06:29 PM

I'll try now and let you know. Thanks a lot for your help. By the way is there a way to deactivate one field when another is selected?

Lynne 08-14-2009 06:42 PM

Quote:

Originally Posted by ramil86 (Post 1867386)
By the way is there a way to deactivate one field when another is selected?

Not using default vbulletin, no. You would have to write some javascript to do this.

ramil86 08-14-2009 06:59 PM

I get the following erro when trying to use the conditions in my postbit

The following error occurred when attempting to evaluate this template:

Code:

Parse error: parse error in C:\wamp\www\students.kg\includes\adminfunctions_template.php(3939) : eval()'d code on line 54

This is likely caused by a malformed conditional statement.
It is highly recommended that you fix this error before continuing,
but you may continue as-is if you wish.

Here's my code

PHP Code:

<if condition="$post['field7'] == 'student"
    
University$post[field6
<else />
   <if 
condition="$post['field7'] == 'abiturient"
      
School$post[field8
   <else />
     <if 
condition="$post['field6']"
        
University$post[field6
     </if>  
   </if> 
</if> 


Lynne 08-14-2009 07:14 PM

I forgot a single quote:
HTML Code:

<if condition="$post['field7'] == 'student'">
AND
<if condition="$post['field7'] == 'abiturient'">

(Sorry about that.)

ramil86 08-14-2009 07:27 PM

woow that seems to work but can i also display the status as well above the univer/scholl

can i do something like this

PHP Code:

<if condition="$post['field7'] == 'student'">
    
Status:  $post['field7']
    
University$post[field6
<else />
   <if 
condition="$post['field7'] == 'abiturient'"
      
Status:  $post['field7']
      
School$post[field8
   <else />
     <if 
condition="$post['field6']"
        
Status:  $post['field7']
        
University$post[field6
     </if>  
   </if> 
</if> 


Lynne 08-14-2009 07:36 PM

Yes, that should work fine. But, I'd put a <br /> after $post['field7'] so you have a break between lines. You might want to actually put that line before the conditions there since you will always be showing it.


All times are GMT. The time now is 01:04 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.01230 seconds
  • Memory Usage 1,758KB
  • 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
  • (2)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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