SID-01302: Search and Categorize
| Status: |
Answered |
TWiki version: |
5.0.2 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
Linux SLES 11 |
Last update: |
14 years ago |
I have topics with a formfield 'Category' and I need to do a single search and to display topics under different categories.
For example if I have topics under categories Apples Oranges and I need to display the topics under each category
Apples
Topic 1
Oranges
Topic 3
Topic 4
Is there anyway to achieve something similar with a single search ?
--
RonMascarenhas - 2011-10-23
Discussion and Answer
You can do that by assigning each search hit to a
SpreadSheetPlugin variable, using one variable per category.
Here is an example doing a SEARCH on the latest 30 support questions. We keep two spreadsheet variables:
StatusAsked containing the list of topics with status "Asked", and
StatusAnswered containing the list of topics with status "Answered". We then use the LISTMAP function to iterate over the list to create table rows showing all topics of a category:
| Status Asked: |
| SID-02523: Restoring a parent-less web from Trash |
| SID-02522: Regex search: lookaheads |
| SID-02519: TWiki causes an error when accessed through VPN |
| SID-02516: Manage link seems to be incorrectly retrieved |
| SID-02515: Locked down Main web blocks user Watchlist topic creation |
| SID-02513: Safari WebLeftBar not aligned |
| SID-02512: The save script can only be called with POST method. |
| SID-02508: Paypal link on Twiki VM page is broken |
| SID-02505: TOC link doesn't match generated anchor |
| SID-02504: How to select a different store for each web? |
| SID-02499: SSO using shibboleth and apache for twiki issues |
| SID-02497: Create table with unlinked item states (%CLI%) |
|
|
View the raw topic for details.
--
PeterThoeny - 2011-10-24
Thanks Peter that solution suits me fine.
However just for my information , is there any way to generate the list, not knowing beforehand what the categories would be. For example there may be many categories or maybe the categories keep increasing and I don't want to have to edit the search every time.
--
RonMascarenhas - 2011-10-24
You could simply do a SEARCH and sort by the category, such as with
order="formfield(Category)". Details in
VarSEARCH.
--
PeterThoeny - 2011-10-25
--
RonMascarenhas - 2011-11-18
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.