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 11-05-2015, 09:51 PM
tiztoz tiztoz is offline
 
Join Date: Aug 2015
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding comma when needed in custom profile (postbit legacy)

I have created two custom profile fields.
the first one includes 20 teams and the user can choose only one
the second has also 20 teams and the user can choose only one.


This is my code :

Code:
<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11] , $post[field12]</div></if>


The problem with my code is that it always puts the comma , I want it to add the comma only if the user chooses two teams ( one from each group) , while if the user chooses only one team , it does not add the comma.
Reply With Quote
  #2  
Old 11-06-2015, 05:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do they have to choose something in each field - 11&12? Or only in one field - only in 11? Give us some of those details and then we can write up some conditions.
Reply With Quote
  #3  
Old 11-06-2015, 05:47 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11]<if condition="$post['field12']"> , $post[field12]</if></div></if>
Would this not work?
Reply With Quote
3 благодарности(ей) от:
MarkFL, sa3eka, tiztoz
  #4  
Old 11-06-2015, 06:13 PM
tiztoz tiztoz is offline
 
Join Date: Aug 2015
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by PinkMilk View Post
Code:
<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11]<if condition="$post['field12']"> , $post[field12]</if></div></if>
Would this not work?
Works like charm :up:
Reply With Quote
Благодарность от:
MarkFL
  #5  
Old 11-07-2015, 09:22 AM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by PinkMilk View Post
Code:
<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11]<if condition="$post['field12']"> , $post[field12]</if></div></if>
Would this not work?
You will still get the comma if field 11 is left blank. try this:
Code:
<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11] <if condition="$post['field11'] AND $post['field12']">, </if><if condition="$post['field12']">$post[field12]</if></div></if>
This will leave out the comma if only 1 field is selected, but show it, if both have a value.
Reply With Quote
  #6  
Old 11-07-2015, 05:41 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, if field11 is left blank, nothing will show because of the initial condition around the whole line.
Reply With Quote
  #7  
Old 11-07-2015, 10:01 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Actually, if field11 is left blank, nothing will show because of the initial condition around the whole line.
Yep, I missed that. Here is the corrected code

Code:
<div class="CommUserInfo">team :  <if condition="$post['field11']">$post[field11]</if><if condition="$post['field11'] AND $post['field12']">, </if><if condition="$post['field12']">$post[field12]</if></div>
If you want to hide the entire line if neither field has a value: (not tested, but it should work)
Code:
<if condition="$post['field11'] OR $post['field12']"><div class="CommUserInfo">team :  <if condition="$post['field11']">$post[field11]</if><if condition="$post['field11'] AND $post['field12']">, </if><if condition="$post['field12']">$post[field12]</if></div></if>
Reply With Quote
2 благодарности(ей) от:
Lynne, tiztoz
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 10:17 PM.


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.04012 seconds
  • Memory Usage 2,233KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (6)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete