 |
To sort by a UDF, simply add a sort value like the following to your query.
T A G C O D E:
The following will sort by film title from a to z:
<dpQuery sort="userField:film title">
The following will reverse sort by film title from z to a:
<dpQuery sort="-userField:film title">
And the following will first sort by film title, then by issue:
<dpQuery sort="userField:film title" sort="issue">
Here are a few real life examples:
<dpQuery issue="all" userField="film genre" sort="userfield:film title"
sort="fuzzy" max="4">
<dpUserField name="film title"><br>
</dpQuery>
The above query looks through "all" issues, matching any stories based on
film genres. It then sorts the output alphabetically by "film title", then
does a "fuzzy" sort for the best matches. To shorten this list for our demo, we set the max output to 4:
Apocalypse Now
Grand Illusion
Since You Went Away
Welcome to Sarajevo
Here's the same basic query with a reverse sort:
<dpQuery issue="all" userField="film genre" sort="-userfield:film title"
sort="fuzzy" max="4">
<dpUserField name="film title"><br>
</dpQuery>
Output:
Welcome to Sarajevo
Since You Went Away
Grand Illusion
Apocalypse Now
Sorting by UDFs allows you to organize your output alphabetically. It is also the ideal way to create lists of UDF values.
See also:
<dpQuery>,
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>
|
 |