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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2009, 09:05 AM
ramil86 ramil86 is offline
 
Join Date: Apr 2009
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Profile fields with conditions

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?
Reply With Quote
  #2  
Old 08-14-2009, 02:32 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 08-14-2009, 05:07 PM
ramil86 ramil86 is offline
 
Join Date: Apr 2009
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 08-14-2009, 06:16 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 08-14-2009, 06:29 PM
ramil86 ramil86 is offline
 
Join Date: Apr 2009
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 08-14-2009, 06:42 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 ramil86 View Post
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.
Reply With Quote
  #7  
Old 08-14-2009, 06:59 PM
ramil86 ramil86 is offline
 
Join Date: Apr 2009
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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> 
Reply With Quote
  #8  
Old 08-14-2009, 07:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I forgot a single quote:
HTML Code:
<if condition="$post['field7'] == 'student'">
AND
<if condition="$post['field7'] == 'abiturient'">
(Sorry about that.)
Reply With Quote
  #9  
Old 08-14-2009, 07:27 PM
ramil86 ramil86 is offline
 
Join Date: Apr 2009
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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> 
Reply With Quote
  #10  
Old 08-14-2009, 07:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
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 01:45 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.04032 seconds
  • Memory Usage 2,285KB
  • Queries Executed 14 (?)
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
  • (1)bbcode_code
  • (2)bbcode_html
  • (3)bbcode_php
  • (1)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
  • (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