Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

Hide sentence in delimiter if CB field is empty

5 years 8 months ago #311255 by matthewdavey
How do I code to hide if field is empty in delimiter?
lets say you have,
Hi my age is [cb_age] and I live at home.
If the user doesn't fill that field in profile [cb_age] the sentence wont appear in the delimiter field in the cb tab.
I want to hide the sentence if [cb_age] field is empty

thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
5 years 8 months ago #311270 by krileon
Use an IF substitution around your content. See the bottom of the substitution tutorial below for examples.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.

5 years 8 months ago #311291 by matthewdavey
Replied by matthewdavey on topic Hide sentence in delimiter if CB field is empty
I see but I cant seem to hide the sentence if [cb_age] field is empty
I want If [cb_age]  field is empty in the sentence do not display sentence.

[cb:if user="#displayed" username="admin"]This is  [username] my age is #: [cb_age] .[/cb:if]
That works but it uses username="admin.

It hides if username is different but I dont want anything to do with username=
I want all users to see even PUBLIC.
I want it to display at all times except if the user hasn't filled in that particular field.
Can you see the function I need?

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
5 years 8 months ago #311312 by krileon
If cb_date is a date or datetime field then it's unlikely to be empty. It'll be 0000-00-00 for date fields or 0000-00-00 00:00:00 for datetime fields if nothing is selected.


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.

5 years 8 months ago #311349 by matthewdavey
Replied by matthewdavey on topic Hide sentence in delimiter if CB field is empty
I understand date field but I need,
This is [username] my age is [cb_age]
I want If [cb_age] field is empty in the sentence do not display sentence.
its not a date field. its a text field.

What would be the code [cb:if statement that you suggested in an earlier post.

I want all users to see even PUBLIC. unless [cb_age] field is empty. then do not display sentence.
Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
5 years 8 months ago #311359 by krileon
You need to surround it with an IF substitution as suggested above. Example as follows.

[cb:if cb_age!=""]DISPLAYS IF AGE IS NOT EMPTY[/cb:if]

See the substitution tutorial below for further usage information.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.
The following user(s) said Thank You: nant, matthewdavey

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

Moderators: beatnantkrileon
Powered by Kunena Forum