HTML conditional text filters with Search Filter Sets

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
KayJay
Propeller Head
Posts: 23
Joined: Tue Nov 29, 2016 7:19 am

HTML conditional text filters with Search Filter Sets

Post by KayJay »

Hi All, just wanted to share something I've been toying around with in my HTML output.

Inspired by Thomas Tregner's great post about how to use version filters, I've been trying these out in my project (filtering by user role instead of version number, but I'll refer to version here for simplicity).
One concern though was that searches would still return all the content, even topics that may not be relevant to this particular version, and that with the filtering operational, users may even not be able to see the keywords they searched for. Alternatively, we may want to hide content from the search results for some other unspecified reason. This can be addressed at a topic level with MadCap's Search Filters, but how can these by leveraged alongside the version filter so you don't have to select from a drop-down menu twice (once for filtering the page and once for )?

The answer:
  1. Add concepts to each topic to indicate the features/version/some dimension they are relevant for. Only topics with a concept that is included in the eventual filter will be shown in the search results.
  2. Create Search Filter Sets for each version, using the same text as each option's "value" attribute for the version filtering. Add all the relevant concepts.
  3. Add the Search Filter Set to your target.
  4. Add this jquery code to your version filtering script so that when a different version is selected, the search filter is also updated.

    Code: Select all

    $(".search-filter", $(".search-bar-container")).data('filter', e.options[e.selectedIndex].value)
    This is at the end of the ShowHideVersion() function in Thomas' code. I'm implementing the version filtering slightly differently, but I guess this should be around the right context.
You can user your browser's console to check which filter is currently selected at any time with

Code: Select all

$(".search-filter", $(".search-bar-container")).data('filter')
Hiding the filter icon is not really simple, because some of the Flare's default jquery scripts use .show() at intervals. My workaround has been in css:

Code: Select all

.search-filter-wrapper {
	width: 0;
	border: none;
}
I hope this helps anyone who is trying to hack their Search Filter Set use!
Post Reply