SID-00361: How to Implement Advanced Alphabetization of SEARCH results
| Status: |
Answered |
TWiki version: |
4.3.1 |
Perl version: |
5.10.0 |
| Category: |
CategorySearch |
Server OS: |
Windows XP Professional |
Last update: |
16 years ago |
By default, the SEARCH tool sorts results alphabetically, but often there are exceptions to standard alphabetization.
For instance, in our search results, we would like to list "St. George" alongside "Saint George" or "Mc Caullough" beside "Mac Caullough".
I thought that I could create a formfield where we could be more explicit about the alphabetization, by which I mean spell out each entry in full as we would want it to be sorted, and then direct SEARCH to sort by that field. Unfortunately, that doesn't seem to have worked.
When I implement the following, the results are simply sorted by the name of the topic, not by formfield(
AlphaTopic) as defined below:
%SEARCH{"[S]ource.*value\=.*[W]ebListVerified" regex="on" scope="text" excludetopic="Web*" casesensitive="on" nosearch="on" nototal="on" web="all" order="formfield(
AlphaTopic)" format="$formfield(
TopicName) — $formfield(Supplementary)"}%
If however, I put the search results into a table and then use the TABLE plugin to sort by
AlphaTopic, I do get the expected results.
--
DanKerr - 2009-06-09
Discussion and Answer
A way to do this is to format the search result as a table, and use the table's "initsort" attribute. If you don't want the sorted results displayed in a table, hide it in HTML comments, and then use CALC's LIST functions to pull the results from there and redisplay them.
--
SeanCMorgan - 2009-06-09
Thanks for the very quick reply Sean. I'll give that a try and report back.
--
DanKerr - 2009-06-09
I produced a table with correctly-sorted results, hid the table in HTML comments, pulled the data out using %CALC{"$LIST(R2:C1..R300:C3)"}% but the results of that formula are displayed sorted by topic name, not the way the table is sorted!
How frustrating.
--
DanKerr - 2009-06-09
Alternately, would it be possible to hide the sorted column (in this case, formfield(
AlphaTopic)?) Or, at the worst, mask it in some way (white text on white background?)
Thoughts?
--
DanKerr - 2009-06-10
Like so:
<div style=display:none>hide me</div>
See
SearchOrderOnMoreColumns for an example of that.
--
SeanCMorgan - 2009-06-10
Genius! Thanks Sean.
I was able to use the TABLE plugin to format the results so that they looked pretty much the way I wanted.
The solution then is to create a formfield which contains an appropriate string which guides TWiki to alphabetize/sort your results, then include that in a column of your results table. Finally, hide the alphabetization/sort formfield from the user with a <div style=display:none>formfield(Alpha)</div>
Most appreciated on my part.
--
DanKerr - 2009-06-11
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.