Skip to Content Skip to Menu

Field concatenation / substitution in profile for CB

  • cgwhite
  • cgwhite
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 0
6 years 11 months ago #298501 by cgwhite
I am just wondering how I can concatenate two fields into a single string field and display it in the profile. I assume that I can use the substitution bot and achieve this but is there another way.

Currently I have the following displaying on the profile:

Label 1: Data1 from Field1
Label 2: Data2 from Field2


What I want to achieve is:

(Data1 + Data2) = Data3 <Field3>

Label1: Data3 from Field3

Is this possible within CB.

Regards,

Chris.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 11 months ago - 6 years 11 months ago #298515 by krileon
You're wanting to actually add the 2 dates together? The only way to do that is either CB Query Field or CB Code Field. You'll have to query for and combine the values in your SQL in a Query field or use PHP to add the two values together in a Code. If you need it actually stored in the database you'll have to use CB Auto Actions and its format functions to try and add the two together. If you just want to display both values in a single field you'd just substitute them into a Custom HTML field.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 6 years 11 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • cgwhite
  • cgwhite
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 0
6 years 11 months ago #298545 by cgwhite
Thank you for your reply... It was Data1 and Data2 not Date1 / 2.

These are two text fields that I wish to display on the same line rather than one below the other. i.e. in a grid rather than a column.

So yes: " If you just want to display both values in a single field you'd just substitute them into a Custom HTML field." Can you please explain how I would substitute them into a Custom HTML Field please. I have 9 sets of data that I wish to do this for.

Regards,

Chris.

Please Log in or Create an account to join the conversation.

  • cgwhite
  • cgwhite
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 0
6 years 11 months ago #298549 by cgwhite
Thank you, I have now sorted this out. I have created a Custom HTML field, [concatenated_field], into which I have placed the 2 fields i.e. [field_1] [field_2] and then hidden this on the profile edit screen. On the profile screen I have hidden [field_1] and [field_2]. The two fields then get substituted into the concatenated field and display as I want.

Great help.

Please Log in or Create an account to join the conversation.

  • cgwhite
  • cgwhite
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 0
6 years 11 months ago #298550 by cgwhite
OK, continuing on with this discussion. I now have 3 fields inside a custom html field: [cb_field1] [cb_field2] [cb_field3]

This is fine and displays well, but I wanted to put the 3rd field inside brackets: [cb_field1] [cb_field2] ([cb_field3]) so that I would get something like: "Chris White (UK)" displayed on the profile. Again this works fine so long as the 3rd field is populated. If it is not then you get "Chris White ()" displayed on the profile which does not look very good. I have tried playing around with [cb:if /] statements but can't seem to get anything to work correctly

The last attempt I had was [cb_field1] [cb_field2] [cb:if [cb_field3]!=""]([cb_field3])[/cb:if]

But this did not work either... What am I doing wrong?

Regards,

Chris.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 11 months ago #298559 by krileon

The last attempt I had was [cb_field1] [cb_field2] [cb:if [cb_field3]!=""]([cb_field3])[/cb:if]

Remove the brackets in your IF substitution usage where you've supplied the field and that'll work fine. So it should be as follows.

[cb_field1] [cb_field2][cb:if cb_field3!=""] ([cb_field3])[/cb:if]

Note you're using [FIELD_NAME] substitutions, which are raw database values. If you want them formatted (e.g. in the case of date fields this can be important) then be sure to use [cb:userfield field="FIELD_NAME" /]. Example as follows.

[cb:userfield field="cb_field1" /] [cb:userfield field="cb_field2" /][cb:if cb_field3!=""] ([cb:userfield field="cb_field3" /])[/cb:if]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum