Flow Control
Flow control tags relate to conditional statements, and looping constructs. The most common use of a flow control tag is a <dpIf> statement. Using <dpIf> you can perform tests within your template to decide how you want your page to render. For example, testing the character count of a story to decide how to present the images, ads, suggested links, or even if you want to split the story into multiple pages.
<dpIf>
D E F I N I T I O N:
Conditional tests allow you to make comparisons within your templates. For example, you can calculate how many characters are in a story, and provide a special layout for each circumstance.
Simple Condition Syntax
<dpIf (comparison statement)>
action
</dpIf>
Complete Condition Syntax
<dpIf (comparison statement)>
action
<dpElseIf (comparison statement)>
action
<dpElse>
action
</dpIf>
C O M P A R I S O N O P E R A T O R S:
| = | equal |
| != | not equal |
| in | is in set |
| not | not in set |
| gt | greater than |
| lt | less than |
E X A M P L E S:
The following can be read as "If the section for this story is music, then display the message You're in the music section":
<dpIf <dpSection>="music">
You're in the music section
</dpIf>
The following can be read as "If the section for this story is music, then display the message You're in the music section, else (otherwise) display You're not in the music section":
<dpIf <dpSection>="music">
You're in the music section
<dpElse>
You're not in the music section
</dpIf>
The following can be read as "If the section for this story is music, then display the message 'You're in the music section', else if the section for this story is film, then display the message 'You're in the film section', else (otherwise) display 'You're not in the music or film section' ."
<dpIf <dpSection>="music">
You're in the music section
<dpElseIf <dpSection>="film">
You're in the film section
<dpElse>
You're not in the music or film section
</dpIf>
The following can be read as "If you're not in the film section, display the message Go to the film section":
<dpIf <dpSection> != "film">
Go to the film section.
</dpIf>
<dpLoop>
D E F I N I T I O N:
Looping is most commonly used to step through a story, headline or other display tag by paragraph or font. However you can use it for whatever you want.
<dpLoop var="variable" from="#" to="#" step="#|-#">
Instructions to repeat.
</dpLoop>
A T T R I B U T E S:
E X A M P L E S:
<dpLoop var="i" from="1" to="10">
<dpVar i>
</dpLoop>
would create: 1 2 3 4 5 6 7 8 9 10
<dpLoop var="i" from="2" to="10" step=2>
<dpVar i>
</dpLoop>
would create: 2 4 6 8 10
<dpLoop var="x" from="1" to="<dpImageCount>">
<dpImage number="<dpVar x>">
</dpLoop>
would list all of the images in the story
<dpLoop var="x" from="1" to="<dpLength unit="p"><dpStory></dpLength>">
Paragraph #<dpVar x><p>
<dpStory start="resume" length="<dpVar x>p"><p>
</dpLoop>
would loop through the story one paragraph at a time from the first paragraph to the last paragraph. It would display the paragraph number followed by the paragraph itself.
| Home: Support: Reference Guide: Flow Control | Questions? Comments? Please write support@desert.net. |