Skip to Content Skip to Menu

[solved] question about complex cb:if statements

  • ThePiston
  • ThePiston
  • OFFLINE
  • Posts: 334
  • Thanks: 26
  • Karma: 1
10 years 4 months ago - 10 years 4 months ago #246432 by ThePiston
Should this output something or is it too complex for cb content module? I checked the substitution article but it doesn't say anything about using CB fields in an if statement.

[cb:if cb_2014vopac >= 750 && cb_2014llf >= 250]
<img src='images/icons/medal_plat.png' title='Platinum Status' height='14px' width='14px'>
[/cb:if]

It's looking at CB fields to check their amounts and displaying a certain image if the amount is within a certain range. I can get it to work using regular php, but not using this code above.

PS, I also tried bracketing the fields like this:

[cb:if [cb_2014vopac] >= 750 && [cb_2014llf] >= 250]<img src='images/icons/medal_plat.png' title='Platinum Status' height='14px' width='14px'>[/cb:if]

Thanks

CB 2.3, CBsubs 4.3, PHP 7.1, J! 3.9.X
Last edit: 10 years 4 months ago by ThePiston.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
10 years 4 months ago #246473 by krileon
Replied by krileon on topic question about complex cb:if statements
There's a few issues with the usage. You've spaces between the operator and the values, there should be no spaces except for the include operators. There are no quotes around your value, there should be. Also no you don't place brackets around them. It's also best to use "and" or "or" instead of the shortcut "&&" and "||". Your substitution should be as follows.

[cb:if cb_2014llf>="250" and cb_2014vopac<="750"]
<img src="images/icons/medal_plat.png" title="Platinum Status" height="14px" width="14px">
[/cb:if]

Please note single quote is not valid in an html element. It should always be " and not '. I've also corrected this in the above example. I also assume you meant you want the value within 250-750, but you were checking that it was >= both 750 and 250. It now checks that it's >= 250, but <= 750.

Please see the below tutorial for further substitution usage information.

www.joomlapolis.com/support/tutorials/107-use-cases/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.

Moderators: beatnantkrileon
Powered by Kunena Forum