Tags:
create new tag
view all tags

SID-01055: How to show heading 1 text rather than topic name in search

Status: Answered 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:

View topic Statistics for TWiki Web TWikiGuest 2026-01-07 - 13:13
View topic Ubuntu PeterThoeny 2023-07-15 - 21:08
View topic TWiki Documentation PeterThoeny 2022-08-09 - 03:13
View topic Reset Password PeterThoeny 2022-01-05 - 09:13
View topic TinyMCE FAQs PeterThoeny 2021-09-07 - 17:20
View topic TinyMCE Editor Help Summary PeterThoeny 2021-09-07 - 17:17
View topic Welcome, Main.TWikiGuest! TWikiGuest 2019-10-31 - 23:12
View topic TWiki Text Formatting PeterThoeny 2017-12-18 - 07:19
View topic Administrator Skills Assumptions PeterThoeny 2015-09-01 - 09:07
View topic TWiki Reference Manual PeterThoeny 2014-12-16 - 01:38

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 View topic 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

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title How to show heading 1 text rather than topic name in search
SupportCategory CategorySearch
TWiki version 4.3.2
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2010-12-14 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.