If Statement conflict?

7 years 9 months ago #284084 by michaelgreen252
If Statement conflict? was created by michaelgreen252
Im hoping you guys can tel me a better way to achieve my outcome or maybe i can adjust my code a little better...

I have 2 fields ..cb_genre(which has sever values like alternateve,rap,rock) .....and ....cb_type(which has several values like hard,soft,fast)

and lastly i have 2 html fields named (cb_see_soft, and cb_see_hard) which i use an (and) statement to join them and produce a link (im doing this becuase i have quite a few plans to show and i would rather not have to create a new field for each..

now..my issue. it works well and outputs the link when the user has only selected one value foe each field....for example...(he ihas chosen cb_genre [value=rock] and cb_type[value=fast]
........but when the user has chosen 1 value in cb_genres (rock) and 2 values in the cb_type[fast] and [slow] ....
it does not show anything at all.

My question #1 is...is there a better way to use several if statements in one html field to show the conditions thats being met? it seems since one condition is applied twice

heres the code below for both of the html fields what im using if statements to show a llink if both fields are met...

[cb_see_soft]

<p>[cb:if cb_genres ="alternative" and cb_type="soft"] go tho this link [/cb:if]</p>
<p>[cb:if cb_genres ="country" and cb_type="soft"] check the link here [/cb:if]</p>
<p>[cb:if cb_genres ="dance_hall" and cb_type="soft"] check the flink here [/cb:if]</p>
<p>[cb:if cb_genres ="gospel" and cb_type="soft"] check thhe link here [/cb:if]</p>
<p>[cb:if cb_genres ="pop" and cb_type="soft"] check the fucking rap battle herelinkucking rap battle here [/cb:if]</p>
<p>[cb:if cb_genres ="rb" and cb_type="soft"] check the link [/cb:if]</p>

[cb_see_hard]

<p>[cb:if cb_genres ="alternative" and cb_type="hard"] go tho this link [/cb:if]</p>
<p>[cb:if cb_genres ="country" and cb_type="hard"] check the link here [/cb:if]</p>
<p>[cb:if cb_genres ="dance_hall" and cb_type="hard"] check the flink here [/cb:if]</p>
<p>[cb:if cb_genres ="gospel" and cb_type="hard"] check thhe link here [/cb:if]</p>
<p>[cb:if cb_genres ="pop" and cb_type="hard"] check the fucking rap battle herelinkucking rap battle here [/cb:if]</p>
<p>[cb:if cb_genres ="rb" and cb_type="hard"] check the link [/cb:if]</p>

Please Log in to join the conversation.

7 years 9 months ago - 7 years 9 months ago #284099 by krileon
Replied by krileon on topic If Statement conflict?
A multi-select fieldtype stores its values as follows.

VALUE_1|*|VALUE_2|*|VALUE_3

So using an equal to operator can't work for such a value. You need to use the regexp operators to do an inline match. Example as follows.

<p>[cb:if cb_genres=~"/alternative/" and cb_type="soft"] go tho this link [/cb:if]</p>

Now if you want it to match multiple values in that select value you'd use the below for example.

<p>[cb:if cb_genres=~"/alternative|country/" and cb_type="soft"] go tho this link [/cb:if]</p>

See the below tutorial for further substitution 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: jgardounis

Please Log in to join the conversation.

7 years 9 months ago #284270 by michaelgreen252
Replied by michaelgreen252 on topic If Statement conflict?
hey thanks for the last suggestion and sorry for my late reply.. it worked perfectly and.
How about this scenario using the hit count..

im trying to show one content if hits are greater than 50..and another example if hits are greater than 100 and another if hits are greater than 200 so i used the statements below

[cb:if hits >"50"] just a few hits [/cb:if]

[cb:if hits >"100"]decent amount of hits[/cb:if]

[cb:if hits >"200"]lots of hits [/cb:if]


it works and shows each once met..but if all 3 if statements are met it shows all three...
My question is ..is there any way to hide the (if: 50 hits and the hide 100 hits if ..200 hits are met)
thanks for any help

Please Log in to join the conversation.

7 years 9 months ago #284292 by krileon
Replied by krileon on topic If Statement conflict?
You can have multiple checks on 1 IF using and/or statements. In your case to do an integer range you could use the below for example.

[cb:if hits>"50" and hits<"100"] just a few hits [/cb:if]

This way it should only show if hits are greater than 50, but less than 100. Your 100 one would check if greater than 100, but less than 200 and your 200 one would just stay as is.


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: paxx

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.222 seconds

Facebook Twitter LinkedIn