Search on a subset of topics automatically

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
whunter
Sr. Propeller Head
Posts: 429
Joined: Thu Mar 12, 2009 4:49 pm
Location: Portland, OR

Search on a subset of topics automatically

Post by whunter »

Here's what I want to do:
* Flag a subset of topics in my help file with a specific concept tag.
* Create a page in the help with a Search bar that automatically searches only the topics with that concept tag (using search filters).

I can flag the topics and create the page, but what I'm stumbling on is that I don't see any way to configure the Search Bar Proxy to use a specific search filter.
Is there a way to do this with the Flare functionality?
If not, is there a way to (semi-easily) do this using some scripting or something like that?

Thanks in advance for any assistance!
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Search on a subset of topics automatically

Post by NorthEast »

You can't do this with Flare, so it would require a script.

Inserting this script on the search page would do the job:

Code: Select all

$(document).ready(function(){
   $(".menu").on("loaded", function () { 
      $(".search-filter-content li:contains('Search filter text goes here')").click();
   });
});
In short, it waits for Flare's menus to finish loading, then clicks on the search filter menu item that contains some particular text. Replace 'Search filter text goes here' with some or all of the text as it appears in your search filter menu.
whunter
Sr. Propeller Head
Posts: 429
Joined: Thu Mar 12, 2009 4:49 pm
Location: Portland, OR

Re: Search on a subset of topics automatically

Post by whunter »

Thanks Dave. That works, but there are two issues:

1. The presence of this script on the search page seems to interrupt other scripts that are in the master page (these scripts do things like create an in-page TOC and set a Home link in the breadcrumb). I could set up the search page to use a different master page, but just mentioning in case there's some easy workaround.

2. This is a SideNav project, so there is also a search bar in the top of the skin. While the script does set the search filter in the desired search bar within the topic, it also sets it in the top search bar and unfortunately leaves the filter drop-down open on that search bar. Which is a little confusing. I don't suppose there's any way to target the script just to the search bar in the topic?

Thanks again for any help.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Search on a subset of topics automatically

Post by NorthEast »

1. I can't see why this script would affect your others, but I don't know how you're running the other scripts.

2. If the search bar is inserted using a search bar proxy, then you could put the search bar proxy inside a div; e.g.
<div id="topic-search-bar"> <MadCap:searchBarProxy ... /></div>
So you can then use that div to target that particular search bar in the the script:
$("div#topic-search-bar .search-filter-content li:contains('Search filter text goes here')").click();
whunter
Sr. Propeller Head
Posts: 429
Joined: Thu Mar 12, 2009 4:49 pm
Location: Portland, OR

Re: Search on a subset of topics automatically

Post by whunter »

1. You're right -- it doesn't. I was confused for silly reasons.

2. This resolves the issue where the search filter drop-down is left open in the top search bar. It still sets the search filter for both search bars, but it looks like they just can't be set independently -- if you manually change one, the other changes to match. So I'll live with it!

Thank you so much for the help!
evba
Jr. Propeller Head
Posts: 1
Joined: Fri Sep 18, 2020 8:40 am

Re: Search on a subset of topics automatically

Post by evba »

Hi,

I just tried to make this solution work. On page reload, the search filter is flickering, but nothing seems to happen and no filter is being selected.
Does this solution still work with newer versions of Flare? Or will I have to adjust it?

Thanks for any hints!

Evelin
StormCloud79
Propeller Head
Posts: 20
Joined: Mon Feb 15, 2021 5:11 am

Re: Search on a subset of topics automatically

Post by StormCloud79 »

Hello, jumping on to this old thread I was trying to do this exact same thing but the script no longer seems to work. Did anyone or does anyone know how to achieve selecting one of the filters on page load so that its pre-set to the filter I require?
perrinstewart
Jr. Propeller Head
Posts: 6
Joined: Mon Oct 05, 2015 8:01 am

Re: Search on a subset of topics automatically

Post by perrinstewart »

Same here....anyone know?
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Search on a subset of topics automatically

Post by NorthEast »

The search filter menu was changed for accessibility a while back.

This should work (changed li:contains to button:contains):

Code: Select all

$(document).ready(function(){
   $(".menu").on("loaded", function () { 
      $(".search-filter-content button:contains('Search filter text goes here')").click();
   });
});
perrinstewart
Jr. Propeller Head
Posts: 6
Joined: Mon Oct 05, 2015 8:01 am

Re: Search on a subset of topics automatically

Post by perrinstewart »

So I inserted this at the bottom of my html page using Madcap's Insert > Script function (selecting 'javascript' as the type) and this doesn't seem to work. Should I be adding it to the page some other way? (I tried just adding it to the html code manually without using Madcap's insert function and it displays the code on the page for some reason).
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Search on a subset of topics automatically

Post by NorthEast »

No, that should work - it works ok for me.

Obviously, the text 'Search filter text goes here' needs to be replaced with some/all the text of the actual filter name.
Post Reply