Skip to Content Skip to Menu

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

Hide a custom html field - [cb:if]

  • davisJ
  • davisJ
  • OFFLINE
  • Posts: 51
  • Thanks: 0
  • Karma: 0
8 years 1 month ago #285959 by davisJ
Hide a custom html field - [cb:if] was created by davisJ
Hi,

I'm trying to use [cb:if] statements to show/hide a custom html field if text fields [cb_...] are filled in by users.

So far, I've got:
Code:
<div> [cb:if cb_suburb="" and cb_state="" and cb_country=""/] [/cb:if] [cb:if cb_suburb!="" and cb_state="" and cb_country=""/]<i class="fa fa-home fa-lg"></i>1 [cb_suburb][/cb:if] [cb:if cb_suburb="" and cb_state=!"" and cb_country=""/]<i class="fa fa-home fa-lg"></i>2 [cb_state][/cb:if] [cb:if cb_suburb="" and cb_state="" and cb_country!=""/]<i class="fa fa-home fa-lg"></i>3 [cb_country][/cb:if] ... </div>

When the fields are all empty (ie. none have been filled in), this results in a |home| icon with a 2. I've tried it with 2 different custom fields and sets of text input fields and got the same result both times.

Any ideas why this doesn't work or is there a better way to hide the custom html field when the text fields are all empty? As far as I understand, the conditional plugin does not allow for AND statements.

Cheers

David

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
8 years 1 month ago #285976 by krileon
Replied by krileon on topic Hide a custom html field - [cb:if]
Your usage seams fine except for a minor error in one of the substitutions. Specifically the below.

[cb:if cb_suburb="" and cb_state=!"" and cb_country=""/]<i class="fa fa-home fa-lg"></i>2 [cb_state][/cb:if]

The operator on cb_state is set to =!, but it should be !=.


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, davisJ

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

Moderators: beatnantkrileon
Powered by Kunena Forum