Highlight search results in Top Nav and Side Nav Skins

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
SergeiS
Jr. Propeller Head
Posts: 7
Joined: Tue May 14, 2019 9:18 am

Highlight search results in Top Nav and Side Nav Skins

Post by SergeiS »

Hello.

Just wanted to share our experience with highlighting the search results in HTML5 output that uses the Top Navigation Skin or Side Navigation Skin.
The information provided below is based on our Support Case 153122 with MadCap.

The Tripane Navigation Skin has a built-in set of the relevant settings in it.
In addition, you can configure the span > SearchHighligh, span > SearchHighligh1, ..., span > SearchHighligh10 styles.

The above span > SearchHighligh styles are not supported by the Top Navigation Skin or Side Navigation Skin.
These skins use the b style for highlighting the search results.

In our project, we use the strong style for bold text.

These are the b style settings we used in our project:

Code: Select all

b
{
	mc-hidden: hidden;
	font-size: 1.2em;
	font-weight: bold;
	background: #ffff00;
	background-color: #ffff00;
}
P.S. For more information about the "mc-hidden: hidden", see https://help.madcapsoftware.com/flare20 ... =mc-hidden
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Highlight search results in Top Nav and Side Nav Skins

Post by doc_guy »

I wrote a response to this post, and the forum software ate it for lunch. So here is another attempt.

There are several search results styles that apply to HTML5, TopNav, and SideNav targets. They are done in the style sheet, not in the skin editor.

First, if you want to change how the search terms are displayed on the search results page itself, you have to change the <b> tag. You'll notice that Flare wraps each word from the search term in a separate <b> tag, but it doesn't differentiate the search terms in any other way. So if you are using the <b> tag elsewhere in your project, those settings will apply here as well, and you have to use a complex selector. Thanks to the way MadCap renders the search results, you can use the following code in your CSS to change just the <b> tags on the search results page:

Code: Select all

#searchPane b {
	color:orange
}
Now, if you want to change how search results are styled/highlighted on the topic pages that you open from the search results, then you have two options. First, you can style all the individual search term words with the same style. This is what we do in our project. To do that, just add the following to your CSS style sheet:

Code: Select all

.SearchHighlight
{
	background-color: yellow;
}
Flare gives you an additional option when styling these words. Because of the way Flare generates output, you can actually style each word from the search phrase separately. Here is what Flare renders in HTML output for a two word search:

Code: Select all

<span class="SearchHighlight SearchHighlight1">Term1</span> <span class="SearchHighlight SearchHighlight2">Term2</span>
That gives us the opportunity to use the following code to change the styles/background colors of each word separately:

Code: Select all

.SearchHighlight.SearchHighlight1
{
   background-color: yellow;
}
.SearchHighlight.SearchHighlight2
{
   background-color: orange;
}
.SearchHighlight.SearchHighlight3
{
   background-color: pink;
}
You can keep adding numbers for as many search terms as you need. I don't know if there is an upper limit. This isn't something I've tested, as we only use one background color for all highlighted terms.

I hope this helps explain how you can affect the way search results are displayed in Flare.
Paul Pehrson
My Blog

Image
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Highlight search results in Top Nav and Side Nav Skins

Post by NorthEast »

SergeiS wrote:The above span > SearchHighligh styles are not supported by the Top Navigation Skin or Side Navigation Skin.
These skins use the b style for highlighting the search results.
Just to be clear, that's not correct - the span styles are supported by Top Nav and Side Nav skins, but they're not used for Tripane.

For the Tripane skin, you set the highlight colours in the skin, rather than using those span styles.

I hope MadCap support didn't give you that information!

It's covered in this help topic - the steps for "how to Use Styles to customize Search highlight colors" applies to Top Nav and Side Nav skins:
https://help.madcapsoftware.com/flare20 ... h-Hits.htm
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Highlight search results in Top Nav and Side Nav Skins

Post by doc_guy »

Huh. Didn't know that topic existed. Pointing to it would have been much easier than writing my whole answer! :)
Paul Pehrson
My Blog

Image
Vibeke B
Propeller Head
Posts: 73
Joined: Thu Mar 15, 2018 7:14 am
Location: Denmark

Re: Highlight search results in Top Nav and Side Nav Skins

Post by Vibeke B »

Thank you doc_guy. This is really great and gave me just the info I needed. :D
What if you want to search for two words that hang together? Right now, if I search for 'New Plan' I get all the hits I want, but they are not colored in the result list or the page I jump to. Can I add some lines in my CSS to color this too? If so, what would that be?
Post Reply