Nested If/Else Statements
Permalink Browser Info Environment
This question is purely for discussion only, but is possible to do nested if/else statements? Something like this...
And, if that is possible, what would the order/syntax need to be to throw else statements in there to?
<if name="Phone"> <if name="Phone" comparison="contains" value="601"> You are in the 601 area code. </if> <if name="Phone" comparison="contains" value="602"> You are in the 602 area code. </if> </if>
And, if that is possible, what would the order/syntax need to be to throw else statements in there to?
Type: | Discussion |
---|---|
Status: | New |
If/Else, nested if's and/or multiple matching criteria would be great!
I found a solution to your discussion.
I am busy with creating a tool for our company to keep track of project information. In there is also a status field that I want to give different colors depending the status.
Experimenting with the <if>/<else> feature I wrote the following XML:
Resulting in the attachted file. One remark, with this approach the <else> statement won't work so every option has to be stated with the <if> statement.
I am busy with creating a tool for our company to keep track of project information. In there is also a status field that I want to give different colors depending the status.
Experimenting with the <if>/<else> feature I wrote the following XML:
<if name="Status" comparison="equal to" value="Live"><font color="#0C3"><field name="Status" /></font></if> <if name="Status" comparison="equal to" value="New"><font color="#0044FF"><field name="Status" /></font> </if> <if name="Status" comparison="equal to" value="Ready"><font color="#FF000"><field name="Status" /></font> </if> <if name="Status" comparison="equal to" value="SEO"><font color="#FFB300"><field name="Status" /></font> </if> <if name="Status" comparison="equal to" value="Process"><font color="#FFB300"><field name="Status" /></font> </if> <if name="Status" comparison="equal to" value="Hold"><font color="#FF000"><field name="Status" /></font> </if> </div>
Resulting in the attachted file. One remark, with this approach the <else> statement won't work so every option has to be stated with the <if> statement.
I have need of this too. Can someone from DD chime in?
Thanks!
Thanks!
For what it's worth, asaucier, I used the solution posted by webinter and it does work, though kind of a kludge. So if the developer doesn't have a more streamlined alternative, this does work. -J
I don't think that helps me, though if my logic is off, I'm welcome to suggestions.
I need to only show the records the fulfill two different if statements.
I tried the suggestion posted above and couldn't get it to work with if statements using two different attributes.
This is what I need to do:
Thanks!
I need to only show the records the fulfill two different if statements.
I tried the suggestion posted above and couldn't get it to work with if statements using two different attributes.
This is what I need to do:
<if status="approved"> <if name="Offering Type" comparison="equal to" value="Product"> <li> <a href="{{DETAILURL}}"><field name="Offering Title" /></a> </li> </if> </if>
Thanks!
Hmm, something that might work in your instance, is to put the page in Edit mode, edit the data display block and check the box that only shows approved records. Then you wouldn't need to nest. This won't help you if you need to show unapproved records too, but with the example shown it might give you an avenue. Best of luck. -J
You're brilliant! Now why didn't I think of that??
That'll work for me - thanks a lot!
That'll work for me - thanks a lot!