SID-01055: How to show heading 1 text rather than topic name in search
| Status: |
Answered |
TWiki version: |
4.3.2 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
|
Last update: |
15 years ago |
I am looking for help with a formatted search. I've read through several support tickets and while
ExcludeFirstSummaryLineFromFormattedSearch comes kind of close, it isn't quite what I am after.
In our topics, we use Heading 1 to display the topic name in each topic in title case rather than
WikiWords CamelCase. This is easier for our readers to quickly scan and find the topic they are looking for. Therefore I want our formatted search results to display the text of Heading 1 as a link to the topic; something like this:
[[$topic][heading 1 text]]
To further complicate matters, we markup Heading 1 to repress its display in the TOC (i.e. ---+!!).
This is the current search that I want to reformat to display Heading 1:
%TABLE{ tablewidth="50%"}% %SEARCH{"VDHLP;VDHLPtaxonomy" web="Engineering" scope="text" type="regex" nosearch="on" nototal="on" excludetopic="VdhlpTemplate, HelpSetup, %INCLUDINGTOPIC%" format="| [[$topic]] | $wikiusername | $date |" }%
I am not a coder, so please be very literal in your advice.
Thanks in advance.
- Dean
--
DeanCloutier - 2010-12-13
Discussion and Answer
Apply a
$pattern() in the
FormattedSearch to grab the H1 heading to show as the link label. Example, showing the 10 most recently changed topics in the TWiki web:
The format is as follows:
format="| [[$web.$topic][$percntICON{viewtopic}$percnt $pattern(.*?\-\-\-+\++[\! ]*([^\n\r]+).*)]] | $wikiusername | $date |"
It skips over !! and spaces, and grabs the heading for display. Note that I added a

viewtopic icon in case the topic is missing a H1 heading.
See
RegularExpression details.
--
PeterThoeny - 2010-12-14
Alternatively, use a spaced out topic name:
format="| [[$web.$topic][$percntSPACEOUT{$topic}$percnt]] | $wikiusername | $date |"
See
VarSPACEOUT
--
PeterThoeny - 2010-12-14
--
DeanCloutier - 2010-12-14
SPACEOUT is perfect, not sure how I missed it. It also eliminates potential problems with other collaborators not following a Heading 1 naming convention.
I've used a number of authoring tools over the years, and I can honestly say Twiki support is the best so far; fast, accurate, reasonable alternatives, real solutions.
Thanks,
--
DeanCloutier - 2010-12-14
I am glad you like TWiki's flexibility. Please consider writing a twiki.org blog post on how TWiki solves your collaboration issues. See
BlogIdeas.
--
PeterThoeny - 2010-12-14
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.