Home: Support: Reference Guide: Variables & Macros

Variables & Macros

Variables and Macros allow you to create your own macro subroutines, or save a value in a variable for later use within your template. A common use of macros would be a capsule style layout for your table of contents pages, or a subroutine to create suggested author links. It is also common to place all of your site's macros in their own file that your templates can all reference. Organizing your templates like this, can aid in streamlining and modifying your templates.

<dpMacro>

D E F I N I T I O N:

Macros are similar to variables, but rather than setting a value they define a series of instructions you can use within your template. If you end up doing the same thing more then once within your template, macros are usually a helpful shorthand.

<dpMacro macroName="value">

or

<dpMacro macroName>value</dpMacro>

Macro Usage:

<dpMacro macroName>


A T T R I B U T E S:

Not applicable.


E X A M P L E S:

<dpMacro myCapsuleStyle>
   <b><dpHeadline link="on"></b><br>
   <dpSummary><br>
   <dpAuthor><p>
</dpMacro>

<dpQuery section="music">
   <dpMacro myCapsuleStyle>
</dpQuery>

<dpQuery section="film">
   <dpMacro myCapsuleStyle>
</dpQuery>




<dpMacroDefine>

D E F I N I T I O N:

<dpMacroDefine> is the preferred way of defining macros. By defining macros with <dpMacroDefine> you have the extra advantage of being able to call a macro from within macro definition.

<dpMacroDefine macroName>
  macro
</dpMacroDefine>


A T T R I B U T E S:

Not applicable.


E X A M P L E S:

<dpMacroDefine linkLayout>
  <dpHeadline><br>
  <dpSummary><p>
</dpMacroDefine>

<dpMacroDefine sectionLinks>
  <dpQuery issue="this" section="this">
    <dpMacro linkLayout>
  </dpQuery>
</dpMacroDefine>




<dpVar>

D E F I N I T I O N:

Variables allow you to create your own variables you can use within a template. Variables are usually used to save or set values you want to reference later in your template.

<dpVar variableName="value">

or

<dpVar variableName>value</dpVar>

Variable Usage:

<dpVar variableName>


A T T R I B U T E S:

style="lower|upper|title|spaced|roman|decimal|noHtml|noHtmlStyle|identifier|scriptEncode"

Please refer to the common attributes page for additional details on the style attribute.


E X A M P L E S:

<dpVar myName="Deuteronomy">

My name is <dpVar myName>
would display
My name is Deuteronomy

<dpIf <dpColumnID>="feature">
   <dpVar headerImage="cool_image.gif">
<dpElse>
   <dpVar headerImage="plain_image.gif">
</dpIf>

<img src="<dpVar headerImage>">
would display cool_image.gif if it was the feature and plain_image.gif if it wasn't.




<dpVarDefine>

D E F I N I T I O N:

<dpVarDefine> is the preferred method of defining variables. The advantage to using <dpVarDefine> is the ability to nest variables. Note: all leading and trailing padding is removed from the variable definition.

<dpVarDefine variableName>
  variable
</dpVarDefine>


A T T R I B U T E S:

style="lower|upper|title|spaced|roman|decimal|noHtml|noHtmlStyle|identifier|scriptEncode"

Please refer to the common attributes page for additional details on the style attribute.


E X A M P L E S:

<dpVarDefine myCounter>
  0
</dpVarDefine>

<dpVarDefine myCounter>
  <dpMath <dpVar myCounter> + 1>
</dpVarDefine>




Home: Support: Reference Guide: Variables & Macros
Questions? Comments?
Please write support@desert.net.