Skip to Content Skip to Menu

delimiter if statements for address fields

  • montano
  • montano
  • OFFLINE
  • Posts: 1
  • Thanks: 0
  • Karma: 0
12 years 5 months ago - 12 years 5 months ago #199705 by montano
I think I've just about got this, but not quite.
I'm trying to style the address fields in the profile display and need an if statement so the bullet will not be shown if the user has not provided the information or it's marked as private.
Code:
<ul class="contact-icons"> [cb:if cb_phone="1"]<li class="phone">[cb:userfield field="cb_phone" /]</li>[/cb:if] [cb:if cb_email="1"]<li class="email">[cb:userfield field="cb_email" /]</li>[/cb:if] [cb:if cb_website="1"]<li class="web">[cb:userfield field="cb_website" /]</li>[/cb:if] </ul>
EDIT: Fixed it!! It was the exclamation point
Code:
<ul class="contact-icons"> [cb:if cb_phone!=""]<li class="phone">[cb:userfield field="cb_phone" /]</li>[/cb:if] [cb:if cb_email!=""]<li class="email">[cb:userfield field="cb_email" /]</li>[/cb:if] [cb:if cb_website!=""]<li class="web">[cb:userfield field="cb_website" /]</li>[/cb:if] </ul>
EDIT: Would it be better to add a string to the UL? (if phone or email or website then UL. Anyone know how to do that?
My immediate need is this issue, but I would LOVE to see clear documentation on how to use delimiters. Anyone have a link to all the possibilities?

If there isn't a comprehensive guide, post what you've got and I'll make one and post it up here.
Last edit: 12 years 5 months ago by montano.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
12 years 5 months ago #199760 by krileon

EDIT: Would it be better to add a string to the UL? (if phone or email or website then UL. Anyone know how to do that?

You could use the "or" and have 3 conditions on an IF statement to ensure at least 1 of the conditions is met before rendering a UL. Example as follows.

[cb:if cb_phone!="" or cb_email!="" or cb_website!=""]

My immediate need is this issue, but I would LOVE to see clear documentation on how to use delimiters. Anyone have a link to all the possibilities?

If there isn't a comprehensive guide, post what you've got and I'll make one and post it up here.

Detailed substitution usage information can be found within Tutorials in my signature.


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