Views for Mashups and Mashables : Built-in Presto Views : Template View : Add Conditional Logic
Add Conditional Logic
You may also need templates or custom views to have conditional logic or handle different cases in the results. To add conditions, use these template statements:
*{{if condition}}...{{/if}}: where the condition is any valid JavaScript condition. To check for the presence of a field in the results, use the path to that field as the condition.
*{{else condition}}...{{/else}}: can be used within an if-statement. The condition is any valid JavaScript condition. To check for the presence of a field in the results, use the path to that field as the condition.
*{{else}}...{{/else}}: can be used within an if-statement to provide a default behavior if none of the conditions are true.
To generate the path to a field as part of a condition
1. Place the cursor inside the if or else start-statement
2. Add a space after if or else.
3. Click on the field you want in the Data pane.
Insert the appropriate HTML and other template syntax within the start- and end-statements.
This example change the background color and text color based on the value of a field:
{{if PercentChange > 0}}
<div style="width: 90px;padding: 5px; border: 1px solid #ccc; margin: 5px;float: left;
background-color: #5ab000;color:#fff;">
{{else PercentChange < -3}}
<div style="width: 90px;padding: 5px; border: 1px solid #ccc; margin: 5px;float: left;
background-color: #c11;color:#fff;">
{{else}}
<div style="width: 90px;padding: 5px; border: 1px solid #ccc; margin: 5px;float: left;
background-color: #ff9;color:#333;">
{{/if}}
See If Syntax and Else Syntax for more information on conditional statements in jQuery templates. See Conditional Logic, No Repeating Items and Namespaces for a more detailed example.
Copyright © 2006-2015 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback