Question
Hi all,
I would like to extract the value of a comma separated list and link the items. What I got so far, is a sorted list with the first value and without the duplicates…
%CALC{"$LISTJOIN($n %BR% , $LISTUNIQUE($LISTSORT(%SEARCH{"META\:FORM.*[C]lientProduct;[T]opicClassification.*value\=.*\"(%URLPARAM{ "qt" }%);(Category:) \s*\|.*%URLPARAM{ "qv" default="" }%;%URLPARAM{ "qs" default=""}%" type="regex" regex="on" order="topic" reverse="off" scope="all" nosearch="on" nototal="on" separator=", " excludetopic="*Template" web="Produkte" format="[[%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%?qv=$pattern(.*?Category:\s*?\|\s*(\w+).*)&qs=%URLPARAM{ "qs" encode="url" }%][$pattern(.*?Category:\s*?\|\s*(\w+).*)]]"}%)))"}%
Table I would like to extract…
| Category: | Category1, Category2, Category3 |
But I need to extract all categories, not only the first one… As soon as I change the pattern to
*?Category:\s*?\|\s*(.*)\s.*, the forced linking won’t work anymore. How can I do this?
Environment
--
ThomasEsau - 14 May 2007
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
You might want to consider
RenderTableDataPlugin to read table data.
--
ArthurClemens - 15 May 2007
Thanks for answering. But I don't think, that this plugin can help. My search extracts the content of table, even with the second mentioned pattern, unless I leave the forced linking. In result it would link all extracted items because of the TWikiWord feature… As you see above, I
don’t want to link the results to the source topic, but to somewhere else.
Just to be clear... Following search still works and the topics are linked automatically:
%CALC{"$LISTJOIN($n %BR% , $LISTUNIQUE($LISTSORT(%SEARCH{"META\:FORM.*[C]lientProduct;[T]opicClassification.*value\=.*\"(%URLPARAM{ "qt" }%);(category:) \s*\|.*%URLPARAM{ "qv" default="" }%;%URLPARAM{ "qs" default=""}%" type="regex" regex="on" order="topic" reverse="off" scope="all" nosearch="on" nototal="on" separator=", " excludetopic="*Template" web="Produkte" format="$pattern(.*?category:\s*?\| *(.*?) *?\|.*)"}%)))"}%
But when I use the
[[...]]
or
[[...][...]]
to force a link in the output, the items won't be linked properly:
%CALC{"$LISTJOIN($n %BR% , $LISTUNIQUE($LISTSORT(%SEARCH{"META\:FORM.*[C]lientProduct;[T]opicClassification.*value\=.*\"(%URLPARAM{ "qt" }%);(category:) \s*\|.*%URLPARAM{ "qv" default="" }%;%URLPARAM{ "qs" default=""}%" type="regex" regex="on" order="topic" reverse="off" scope="all" nosearch="on" nototal="on" separator=", " excludetopic="*Template" web="Produkte" format="[[$pattern(.*?category:\s*?\| *(.*?) *?\|.*)]]"}%)))"}%
This is how the output looks like:
...
MicrosoftAccess]]
MicrosoftExcel
MicrosoftExcel]]
MicrosoftInternetExplorer]]
MicrosoftOffice
MicrosoftOffice]]
MicrosoftOutlook
MicrosoftOutlook]]
MicrosoftPowerpoint
MicrosoftPowerpoint]]
MicrosoftVisio
MicrosoftWindows2000
MicrosoftWindows2000]]
MicrosoftWord
MicrosoftWord]]
MiddleOfficeTool
[[AdobeAcrobatReader
...
Topics are partly still linked, but not how there meant to be. Also duplicates are present again and check out the brackets... I believe it has to do with the value of the table, which has to be extracted.
Sometimes there are multiple categories, and sometimes not! These values are always comma separated.
Background: I’ve build a product knowledge base with a search form. After submitting a search, the page will generate an extract of all found topics and also the category list, to which the topics have been assigned to. As soon as the user hits one of the category links, the results will be filtered also by category (or in my case by product). The goal is, to narrow easily the results of the users search.
This solution is established also in the Microsoft knowledge base. Here an example:
http://support.microsoft.com/search/default.aspx?query=error&catalog=LCID%3D1033&spid=&qryWt=&mode=r&cus=False&x=0&y=0
--
ThomasEsau - 16 May 2007
You might want to consider using
FilterPlugin to reformat the list. Personally I would have used the
FormQueryPlugin for this application, but that's just me.
--
CrawfordCurrie - 16 May 2007
The FormQueryPlugin seems to be quite mighty. How ever, it must be possible to wrap the brackets around the items in a proper way in my search. May somebody has an idea or example how to implement it…
--
ThomasEsau - 16 May 2007
Use $TRIM() to remove excessive spaces, use $LISTITEM() to iterate over every element to turn it into a link. SEARCH example on current topic containing a table row with Category:
%CALC{"$LISTJOIN($n %BR% , $LISTMAP([[$item]], $LISTUNIQUE($LISTSORT($TRIM(%SEARCH{"\| Category\: \s*\|.*\|" type="regex" nonoise="on" separator=", " format="$pattern(.*?\| Category\:\s*\| *(.*?) *\|.*)"}%)))))"}%
Resulting in:
Category1
Category2
Category3
--
PeterThoeny - 16 May 2007
That was great help Peter. Thanks!
--
ThomasEsau - 21 May 2007