Mix OR and AND in a CB substitution

4 years 16 hours ago #318249 by chanteur94
Mix OR and AND in a CB substitution was created by chanteur94
Hi

My question is probably stupid but is it possible to mix AND and OR in a same substitution ?

I would like to make something like this : [cb:if (user_id != "0" and cb_stad_nr != "nonregle") or (cb_stad_r ="NULL" and cb_stad_r="regle")]

I know that ( ) are not good but i don't find how to do this with only one cb:if

Help please.

Thank you.

Please Log in to join the conversation.

4 years 15 hours ago #318251 by krileon
Replied by krileon on topic Mix OR and AND in a CB substitution
No, that won't work. All the AND would evaluate and check if they're all valid. If not it would evaluate the OR and check if it's valid. The OR usages are individual. For what you're wanting you'd need to use ELSEIF substitutions like the following.

[cb:if user_id != "0" and cb_stad_nr != "nonregle"]CONTENT_HERE[cb:elseif cb_stad_r ="NULL" and cb_stad_r="regle"]CONTENT_HERE[/cb:elseif][/cb:if]

To avoid duplicating your content as long as this isn't inline you could use a language string for CONTENT_HERE so that either would result in the same language string being output and parsed for whatever content you're wanting to display.

The alternative is to use something like a Code or Query field then put all your conditions in your custom PHP or custom SQL then use an IF substitution against the result of that Code or Query field. It would be interesting to be able to support the conditions you're wanting, but I'm not sure how we would be able to handle that syntax as the REGEXP is already very complicated. Maybe we can implement something that just persists the content. Example as follows maybe something we could implement.

[cb:if PARAMETER="REPLACEMENT"]CONTENT_HERE[cb:elseif PARAMETER="REPLACEMENT"][parent_content][/cb:elseif][/cb:if]

Basically some sort of special substitution of some kind that just outputs the parent conditions content on condition match. Have added a feature ticket as it should be doable.

forge.joomlapolis.com/issues/7980


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 to join the conversation.

3 years 11 months ago #318347 by chanteur94
Replied by chanteur94 on topic Mix OR and AND in a CB substitution
Thank you very much for the answer. I resolve the problem with the cb code field.


But to avoid duplicating my content, you speak about to use a language string for CONTENT_HERE

I know how to create a langage string in the plugin language but it does not work in my article (I use CB content bot).

Best regards.

Please Log in to join the conversation.

3 years 11 months ago #318359 by krileon
Replied by krileon on topic Mix OR and AND in a CB substitution

But to avoid duplicating my content, you speak about to use a language string for CONTENT_HERE

I know how to create a langage string in the plugin language but it does not work in my article (I use CB content bot).

In that case it wouldn't work. It'd depend on the location if that usage would work or not. I've added a feature ticket to see about implementing a special usage though to avoid having to duplicate content if the IF substitution syntax can't be improved to support grouping.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.177 seconds

Facebook Twitter LinkedIn