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...

<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
facerX
View Replies:
jstrong replied on at Permalink Reply
jstrong
If/Else, nested if's and/or multiple matching criteria would be great!
webinter replied on at Permalink Reply 1 Attachment
webinter
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:
<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.
asaucier replied on at Permalink Reply
asaucier
I have need of this too. Can someone from DD chime in?

Thanks!
jstrong replied on at Permalink Reply
jstrong
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
asaucier replied on at Permalink Reply
asaucier
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:
<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!
jstrong replied on at Permalink Reply
jstrong
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
asaucier replied on at Permalink Reply
asaucier
You're brilliant! Now why didn't I think of that??

That'll work for me - thanks a lot!

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.