Improving WebHelp search results in RoboHelp

The full-text search in RoboHelp is an incredibly useful feature. However, scrolling through a list of alphabetized results can be daunting when you are looking for only the most relevant topic to your search keywords.

MadCap has solved this problem by adding a ranking system to the search results in Flare's browser-based help output. I imagine it won't be long before the RoboHelp team does the same.

In the meantime, what if you could alter how topic titles are presented in the WebHelp results pane, so that the best options are easier to find?

With a bit of work, you can.

RoboHelp uses a function called displayTopics in whfhost.js to display WebHelp search results. By adding a bit of JavaScript to this function after you generate your help, you can change how the search results appear.

For example...

In this example, the search sorts out any topics where the search keyword is part of the topic title. These are added to the Recommended section. As you can see, in most cases it will be much easier to find the desired topic quickly.

This modified version uses a JavaScript regular expression.

var rg = new RegExp(gsCW,"ig");

Results are compared to this expression and sorted appropriately before they are displayed.

This particular example assumes that topic titles are well chosen so that those appearing in the recommended list are the most relevant. However, it might not be suitable for projects that have more than several hundred topics. In such cases, even the Recommended list would require scrolling, and users might miss the second list that follows.

The point is, with a bit of scripting skill, you can modify the whfhost.js file and customize the search results. Just make sure your changes will actually benefit users. Also, take time to familiarize yourself with the code before making changes. (Don't worry, this file gets regenerated whenever you compile your help.)

If you need to brush up on your JavaScript skills, try W3Schools tutorials. They have an incredible archive of tutorials that are friendly to non-programmers, and definitely top the list of my favorite resources.

Are you happy with the search functionality just the way it is? No problem. At least you now know the purpose of whfhost.js.

To implement this technique in your own WebHelp system, open the whfhost.js file in your /!SSL!/WebHelp folder, and replace function displayTopics(){ } with the code below. Enjoy!

function displayTopics()

    var recHTML="";
    var sHTML="";
    var sLine="";

    var foundRecTopics = 0;
    var foundAnyTopics = 0;

    var rg = new RegExp(gsCW,"ig");

    var recHead="<dt><nobr><b>Recommended topics</b></nobr></dt>";
    var allHead="<br><dt><nobr><b>Other topics</b></nobr></dt>";

    for(var i=0;i<gaTI.length;i++){
            recHTML+="<dt><nobr><a href='"+gaTI[i].sTopicURL+"'>"+_textToHtml(gaTI[i].sTopicTitle)+"</a></nobr></dt>";
            foundRecTopics = 1;
            sLine+="<dt><nobr><a href='"+gaTI[i].sTopicURL+"'>"+_textToHtml(gaTI[i].sTopicTitle)+"</a></nobr></dt>";


    if (!foundRecTopics) {
        recHTML+="<dt><nobr>No topics found.</nobr></dt>";

        sHTML+="<dt><nobr>No topics found.</nobr></dt>";

    var resultDiv=getElement(gsResultDivID);

Related posts:


  1. Hi Craig,

    An interesting tip but it seems to be a bit too simple. Where does the line of javascript go exactly? Is any more code needed?


  2. I've added the entire modified function, so you can just copy and paste it into your generated whfhost.js file.


  3. Hi Craig,

    I do not believe this works with the WebHelp Pro part of RoboHelp that goes through the RoboEngine. I implemented this script and it does not show up as described. But when not going through the RoboEngine it works great. Thanks for the idea.

  4. Your script is simply great !!
    Thanks Craig for the tip.

  5. I loved your blog entry, but I have ~1,000 topics in a WebHelp file and need something both more robust and configurable.

    We looked at MSSX 2008 (free, but steep learning curve and high maintenance), and I just remembered:

    I saw an ad online about a week ago for a plug-in that crawls your content, enhances your searches, allows you to specify "authoritative entries", in other words, it bolsters and strengthens the weak WebHelp defaULT SEARCH. It seems to me it had a cute name that was like 5 letters long, like Bingo or something?

    This may be annoying (I hope not!), but do you have any idea of the software/plug-in I am talking about?

    I very much appreciate any help you can offer! Thanks in advance!!

  6. @Ian - Thanks for testing in the RoboEngine and sharing your results here. I appreciate it!

    @Naow - Thank you for the feedback! I hope your users enjoy the enhancement.

    @Anonymous - All I could find was Web Search Whacker (WSW). Apparently it allows you to add and remove search data, but I don't know about altering the presentation. Hopefully another HelpScribe reader has heard of the tool you suggested.

  7. Hi Craig--

    The software I mentioned is called Zoom by WrenSoft:

    Has anyone heard good/bad about it?


  8. Hi Anonymus

    Just try out, and there you'll find a lot of stuff about ZoomSearch from Wrensoft. It seems, Peter is quite fond of this software, as he uses it himself on his own webpage.

    Anonymus II

  9. I am using a merged flash help.

    The search functionality works in the individual child help files but on merging the seach does not work in the final merged file.

    Has anyone faced this issue?