Views with Else

By: Matt Grimes | Asked: 09/19/2022
ForumsCategory: General questionsViews with Else
Matt Grimes asked 2 years ago
Do views support [if] [else] [endif]? I need to have quiz results but it doesnt seem like my else rules are working on the views portions    
1 Answers
Rob LeVineRob LeVine answered 2 years ago
Yes. What is the exact statement you're using? "Conditional statements can be used in a View, email message, confirmation message, or redirect URL. "
Matt Grimes replied 2 years ago

[if x equals="something"]Add content here [else]Show this content instead.[/if x]

so this is valid above?

its a laundry list of statements .. i guess i will start off easy:

[if 29="18-24"]Add content here [/if x]
[if 29="25-49"]Add content here [/if x]
[if 29="50-60"]Add content here [/if x]

within each of those "age" backets in have a sub set of rules to implement
[if 29="18-24"]
[if 39="bifocals"]
[/if 39]
[/if 29]

Rob LeVineRob LeVine replied 2 years ago

The syntax is not correct. if needs to be like the following:
[if 29 equals="18-24"]Add content here[/if 29]

Matt Grimes replied 2 years ago

i understand that portion.. its the else portion:

[if 39="bifocals"]
[/if 39]

Bobby Clapp replied 2 years ago

It has to be the word and the symbol "equals=", and not just "=".

Adam Faith replied 1 year ago

Adding onto this 'else' question, I have found that else statements can only deal with a maximum of 3 AND statements before they stop working. For example, the logic if (x AND x AND x AND x AND x) else(y) would not work. Is there any hook that can extend 'else'?

Matt Grimes replied 1 year ago

well that explains that.. mine are very nested, i ended up writing all native php code to do it VS using a view

Victor Font replied 1 year ago

Writing your own shortcode was going to be my suggestion.

Bobby Clapp replied 1 year ago

As noted, you've gone beyond FF capability and would need your own code.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community