 |
In Part 1, we saw how you can use sort="fuzzy" and sort="fuzzier" to find suggested links based on a user field match. In this part we discuss how to fine tune this process.
T A G C O D E:
We have showed queries like this:
Suggested Links:<br>
<dpQuery issue="archives" userField="film genre" sort="fuzzy" max="5">
<dpHeadline link="on"> (<dpUserField name="film genre" number="all">)<br>
</dpQuery>
instead of this:
<dpQuery issue="archives" userField="film genre" sort="fuzzy" max="5">
Suggested Links:<br>
<dpLoop>
<dpHeadline link="on"> (<dpUserField name="film genre" number="all">)<br>
</dpLoop>
</dpQuery>
The reason we are doing this is for ease of readability. When you actually use these queries we always recommend using the latter version with the <dpLoop>. Why? Mainly because of the "Suggested Links:" header. In the first example, the suggested links header will always display regardless of whether any matches are found. The second version will only display the suggested links header if the query is successful. This is a much better approach and the recommended version.
-------
Now, back to sort="fuzzy".
Let's look at the example of matching film genres for a film that may have few genres associated with it:
<dpHeadline> (<dpUserField name="film genre" number="all">)
<p>
Suggested Links:<br>
<dpQuery issue="archives" userField="film genre" sort="fuzzy" max="5">
<dpHeadline link="on"> (<dpUserField name="film genre" number="all">)<br>
</dpQuery>
This could return results like this for the film "I Love You to Death" which is just a comedy.
I Love You to Death (Comedy)
Suggested Links:
The Flim-Flam Man (Comedy)
The Muse (Comedy)
The Ruling Class (Comedy)
The Producers (Comedy)
Bicentennial Man (Comedy)
Granted, those matches are of other comedy films, but they are all over the map and don't necessarily have anything in common with "I Love You to Death" outside of also being funny.
Here's how we can improve the match...
--------
Our examples so far have used only one user field, however our demo publication, Baltimore CityPaper, catalogs a lot more rich meta information about their film reviews, such as film stars (actors), and film directors. Using this additional information, we can refine our query:
<dpQuery issue="archives" userField="film genre" userField="film director" userField="film stars" sort="fuzzy" max="5">
Here it is with all the additional debugging information, so we analyze the results:
<dpHeadline>
(<dpUserField name="film genre" number="all">)
(<dpUserField name="film director" number="all">)
(<dpUserField name="film stars" number="all">)
<p>
Suggested Links:<br>
<dpQuery issue="archives" userField="film genre" userField="film director" userField="film stars" sort="fuzzy" max="5">
<dpHeadline link="on">
(<dpUserField name="film genre" number="all">)
(<dpUserField name="film director" number="all">)
(<dpUserField name="film stars" number="all">)<br>
</dpQuery>
I Love You to Death (Comedy) (Lawrence Kasdan) (Kevin Kline, Tracey Ullman, River Phoenix)
Suggested Links:
Mumford (Comedy) (Lawrence Kasdan) ()
The January Man (Comedy, Suspense) (Pat O'Conner) (Kevin Kline, Harvey Keitel, Susan Sarandon)
Illuminata (Comedy) (John Turturro) (John Turturro)
The Dinner Game (Comedy, Foreign) (Francis Veber) ()
Tapeheads (Comedy) (Bill Fishman) (John Cusack, Tim Robbins)
"I Love You to Death" is a comedy directed by Lawrence Kasden starring Kevin Kline, Tracey Ullman, River Phoenix. Using all of this information, the sort="fuzzy" was able to group the best matches first.
"Mumford" is also a comedy by the same director.
"The January Man" is also a comedy starring Kevin Kline.
The rest are looser matches, but you can see as a database becomes more populated, you have the ability to link to the best matches first.
Next, further refinements for multiple user field matches....
See also:
<dpHeadline>,
<dpUserField>
A D D I T I O N A L < D P Q U E R Y > E X A M P L E S:
S E E A L S O:
Other tag examples that incorporate <dpQuery>
|
 |