Difference between revisions of "SSlogic"

From SmartWiki
Jump to: navigation, search
Line 3: Line 3:
 
<pre>
 
<pre>
 
<!--@sslogic(CONDITION)-->
 
<!--@sslogic(CONDITION)-->
The content to be displayed when condition is true
+
The content to be displayed when condition is true.
 +
This can be more than one line.
 
<!--@end-->
 
<!--@end-->
 
</pre>
 
</pre>
 +
 +
* The content to be displayed (the middle line) can either be in plaintext or in HTML.
 +
 +
  
 
'''Condition''' is replaced with the logical condition that your case calls for. The following code sample will display a Christmas tree image if and only if it is currently December:
 
'''Condition''' is replaced with the logical condition that your case calls for. The following code sample will display a Christmas tree image if and only if it is currently December:
Line 14: Line 19:
 
</pre>
 
</pre>
  
Note that the content to be displayed (the middle line) can either be in plaintext or in HTML.
 
  
 
Often, you will want to display one of two texts--one text in the case that a condition is met and another in the case that the condition is not met. This is achieved through the use of an "else" operator.
 
Often, you will want to display one of two texts--one text in the case that a condition is met and another in the case that the condition is not met. This is achieved through the use of an "else" operator.
The following sample code will display one message if a user is male and another if the user is female:<br>
+
The following sample code will display one message if a user is male and another if the user is female:
 
<pre>
 
<pre>
 
<!--@sslogic('@sex@'='M')-->
 
<!--@sslogic('@sex@'='M')-->
Line 27: Line 31:
  
  
* Using @customfield@ instead of [[Smart Folder|smart folder]] file (like @parent.contract@)
+
The following will display 2 check boxes. If the gender is male the first check box (Male) will be ticked. If the gender is female the second check box will be ticked:
* Use if sslogic like this:
+
<pre>
 +
<!--@sslogic('@parent.owner.clientgender@'='Male')-->
 +
  <input type="checkbox" checked> Male
 +
  <input type="checkbox"> Female
 +
<!--@else-->
 +
  <input type="checkbox"> Male
 +
  <input type="checkbox" checked> Female
 +
<!--@end-->
 +
</pre>
 +
 
 +
You can use multiple sslogic statements if there are more than just 2 options:
 +
<pre>
 +
<!--@sslogic('@possibility@'='Yes')-->
 +
  This will happen for certain.
 +
<!--@end-->
 +
 
 +
<!--@sslogic('@possibility@'='No')-->
 +
  This is not happening.
 +
<!--@end-->
 +
 
 +
<!--@sslogic('@possibility@'='Maybe')-->
 +
  This may or may not happen.
 +
<!--@end-->
 +
</pre>
 +
 
  
 +
You can include more than one condition:
 
<pre>
 
<pre>
<!- -@sslogic(@type@=’contact’) - ->
+
<!--@sslogic('@year@'='2008' AND  ('@month@'='1' OR '@month@'='2')-->
      <!- -@ssattach(after;/files/1234/123/myfilefooter.pdf )- ->
+
  This is only displayed if the year is 2008 and the month is either Jan or Feb.
 +
<!--@end-->
 +
</pre>
  
 +
 +
<pre>
 +
<!--@sslogic(‘@type@’=’contact’) -->
 +
      <!--@ssattach(after;/files/1234/123/myfilefooter.pdf )-->
 
<!--@else-->
 
<!--@else-->
     <!- - @ssattach(after;/files/1234/123/myotherfilefooter.pdf )- ->
+
     <!-- @ssattach(after;/files/1234/123/myotherfilefooter.pdf )-->
 
<!--@end-->
 
<!--@end-->
  

Revision as of 13:18, 2 June 2009

Web Page View fields can use a unique SmartSimple logic interpreter. Web page logic gives you the ability to display certain content or perform certain actions only when specified conditions are met. SmartSimple logic follows the following template:

<!--@sslogic(CONDITION)-->
The content to be displayed when condition is true.
This can be more than one line.
<!--@end-->
  • The content to be displayed (the middle line) can either be in plaintext or in HTML.


Condition is replaced with the logical condition that your case calls for. The following code sample will display a Christmas tree image if and only if it is currently December:

<!--@sslogic(month(now())=12)-->
   <img src='images/xmasstree.jpg'>
<!--@end-->


Often, you will want to display one of two texts--one text in the case that a condition is met and another in the case that the condition is not met. This is achieved through the use of an "else" operator. The following sample code will display one message if a user is male and another if the user is female:

<!--@sslogic('@sex@'='M')-->
  You are a guy.
<!--@else-->
   You are a girl.
<!--@end-->


The following will display 2 check boxes. If the gender is male the first check box (Male) will be ticked. If the gender is female the second check box will be ticked:

<!--@sslogic('@parent.owner.clientgender@'='Male')-->
   <input type="checkbox" checked> Male
   <input type="checkbox"> Female
<!--@else-->
   <input type="checkbox"> Male
   <input type="checkbox" checked> Female
<!--@end-->

You can use multiple sslogic statements if there are more than just 2 options:

<!--@sslogic('@possibility@'='Yes')-->
  This will happen for certain.
<!--@end-->

<!--@sslogic('@possibility@'='No')-->
  This is not happening.
<!--@end-->

<!--@sslogic('@possibility@'='Maybe')-->
  This may or may not happen.
<!--@end-->


You can include more than one condition:

<!--@sslogic('@year@'='2008' AND  ('@month@'='1' OR '@month@'='2')-->
   This is only displayed if the year is 2008 and the month is either Jan or Feb.
<!--@end-->


<!--@sslogic(‘@type@’=’contact’) -->
       <!--@ssattach(after;/files/1234/123/myfilefooter.pdf )-->
<!--@else-->
     <!-- @ssattach(after;/files/1234/123/myotherfilefooter.pdf )-->
<!--@end-->