Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

How can I use CB:IF to check for NULL value in a field?

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago #282451 by fribse2011
I have a field that is set to 'NULL' if it's not set.
I would like to show a specific text when it's null.
So in the Field I've entered a CB:IF under Parameters in the "Profile Value Layout".

I've tried using:
[cb:if cb_type=NULL]My Text[/cb:if]
[cb:if cb_type=""]My Text[/cb:if]
[cb:if cb_type="-"]My Text[/cb:if]
But I don't see it getting 'replaced', I just see the '-' that is set in the configuration for Empty Field Text.

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago #282464 by krileon
[cb:if FIELD_NAME=""]NULL[/cb:if] will match empty string and NULL. Have confirmed this working fine in Custom HTML field.

There does appear to be an issue with content plugins being parsed before substitutions in field layouts though, which could be causing your IF substitution working on the viewing user instead of displayed. If you've CB Content Bot installed try disabling it and seeing if your condition then works. Am fixing the execution order for next nightly.


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.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago #282484 by fribse2011

krileon wrote: [cb:if FIELD_NAME=""]NULL[/cb:if] will match empty string and NULL. Have confirmed this working fine in Custom HTML field.

Where do I then place the text I want it to show instead of the empty string?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago - 8 years 4 months ago #282508 by krileon

Where do I then place the text I want it to show instead of the empty string?

Where NULL is. If you want to display something if a field is empty you'd use the below.

[cb:if FIELD_NAME=""]This field is empty![/cb:if]

If you're doing it with a layout then the below would probably be best.

[cb:if FIELD_NAME=""]This field is empty![/cb:if]
[cb:if FIELD_NAME!=""][value][/cb:if]

Note latest CB 2.x nightly and CB Content Bot 4.0.1 solves the execution order bug mentioned above which could be affecting layouts.


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: 8 years 4 months ago by krileon.

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

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago - 8 years 4 months ago #282597 by fribse2011
Hi Kyle

I did exactly that in the Field Management, under "Profile Value Layout" (it's just when viewing the profile I want it changed), I entered '[cb:if cb_type=""]Ikke medlem[/cb:if]' (which should do that if the field is empty, it should write 'not a member').

The reason is that when a new user is created, and he/she is not yet a member of the club, the field is empty (ie. no member status).
I would like the field to show the text, instead of the 'empty field'.

But I can't make it work.
The field is a single-select dropdown field, if I look in the DB, it is shown as NULL.
Btw. the field is also Ajax editable (if that makes any difference).

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Last edit: 8 years 4 months ago by fribse2011.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago #282611 by krileon
Please ensure you've installed CB Content Bot 4.0.1 if CB Content Bot is installed. Also ensure you've latest CB 2.x nightly. There's a known bug where the layout substitution usage could become based off the viewing user and not the displayed, which is fixed by those 2 releases.


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