Search on a subset of topics automatically
Search on a subset of topics automatically
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!
* 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!
Re: Search on a subset of topics automatically
You can't do this with Flare, so it would require a script.
Inserting this script on the search page would do the job:
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.
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();
});
});
Re: Search on a subset of topics automatically
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.
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.
Re: Search on a subset of topics automatically
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();
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();
Re: Search on a subset of topics automatically
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!
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!
Re: Search on a subset of topics automatically
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
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
-
- Propeller Head
- Posts: 20
- Joined: Mon Feb 15, 2021 5:11 am
Re: Search on a subset of topics automatically
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?
-
- Jr. Propeller Head
- Posts: 6
- Joined: Mon Oct 05, 2015 8:01 am
Re: Search on a subset of topics automatically
Same here....anyone know?
Re: Search on a subset of topics automatically
The search filter menu was changed for accessibility a while back.
This should work (changed li:contains to button:contains):
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();
});
});
-
- Jr. Propeller Head
- Posts: 6
- Joined: Mon Oct 05, 2015 8:01 am
Re: Search on a subset of topics automatically
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).
Re: Search on a subset of topics automatically
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.
Obviously, the text 'Search filter text goes here' needs to be replaced with some/all the text of the actual filter name.