vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Adding comma when needed in custom profile (postbit legacy) (https://vborg.vbsupport.ru/showthread.php?t=320717)

tiztoz 11-05-2015 09:51 PM

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.

Lynne 11-06-2015 05:34 PM

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.

PinkMilk 11-06-2015 05:47 PM

Code:

<if condition="$post['field11']"><div class="CommUserInfo">team :  $post[field11]<if condition="$post['field12']"> , $post[field12]</if></div></if>
Would this not work?

tiztoz 11-06-2015 06:13 PM

Quote:

Originally Posted by PinkMilk (Post 2558331)
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:

Dragonsys 11-07-2015 09:22 AM

Quote:

Originally Posted by PinkMilk (Post 2558331)
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.

Lynne 11-07-2015 05:41 PM

Actually, if field11 is left blank, nothing will show because of the initial condition around the whole line.

Dragonsys 11-07-2015 10:01 PM

Quote:

Originally Posted by Lynne (Post 2558397)
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>


All times are GMT. The time now is 10:08 AM.

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.01091 seconds
  • Memory Usage 1,730KB
  • 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
  • (7)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete