 |
The following macro shows how to control the display of User Defined Field values which contain multiple entries:
T A G C O D E:
Here are a few examples of the values from a User Defined Field of "film genre":
comedy, horror, sci-fi
comedy, horror and sci-fi
comedy and horror and sci-fi
comedy - horror - sci-fi
Change the separators within the macro below to get the different results shown above.
<dpMacro myUserFieldStyle>
<dpVar totalValues="<dpUserField name="<dpVar fieldName>" return="count">">
<dpLoop var="i" from="1" to="<dpVar totalValues>">
<dpIf <dpVar i> = <dpVar totalValues>>
<dpUserField name="<dpVar fieldName>" number="<dpVar i>">
<dpElseIf <dpVar i> = <dpMath <dpVar totalValues>-1>>
<dpUserField name="<dpVar fieldName>" number="<dpVar i>"> and
<dpElse>
<dpUserField name="<dpVar fieldName>" number="<dpVar i>">,
</dpIf>
</dpLoop>
</dpMacro>
To call this macro, use the following tag code:
<dpVar fieldName="film stars">
<dpMacro myUserFieldStyle>
This sets the variable fieldName to "film stars" so the macro knows what UDF to manipulate.
This logic can also be used for other User Defined Fields with values containing multiple entries, such as author and artist names.
See also:
<dpIf>,
<dpLoop>,
<dpMacro>,
<dpVar>
A D D I T I O N A L < D P U S E R F I E L D > E X A M P L E S:
S E E A L S O:
Other tag examples that incorporate <dpUserField>
|
 |