2

I have inserted the Joomla search module in an article.

Now I wish that this module would allow me to search only in the article in which it is present and not throughout the site!

Is it possible?

2
  • What sort of results are you expecting the search module to show when used if it's only for 1 article?
    – Lodder
    Apr 20, 2015 at 9:33
  • I have to search only within a site Faqs! ok? Apr 20, 2015 at 9:47

3 Answers 3

2

No, the Joomla search module will not work to search within a single article. But there are several ways you can make your FAQ more user friendly, depending on how complex it is. Here's a couple of ideas:

  1. Tell the users to press Ctrl + F (or simply F3) to open the in-page search box to search on the current page. This works on all browsers (as far as I know).
  2. Implement a in-page search box using JavaScript. I found the following code that should work, although it's quite old (the site talks about Netscape, a browser from the era of the dinosaurs...):

    var TRange=null;
    
    function findString (str) {
     if (parseInt(navigator.appVersion)<4) return;
     var strFound;
     if (window.find) {
    
      // CODE FOR BROWSERS THAT SUPPORT window.find
    
      strFound=self.find(str);
      if (!strFound) {
       strFound=self.find(str,0,1);
       while (self.find(str,0,1)) continue;
      }
    }
     else if (navigator.appName.indexOf("Microsoft")!=-1) {
    
      // EXPLORER-SPECIFIC CODE
    
      if (TRange!=null) {
       TRange.collapse(false);
       strFound=TRange.findText(str);
       if (strFound) TRange.select();
      }
      if (TRange==null || strFound==0) {
       TRange=self.document.body.createTextRange();
       strFound=TRange.findText(str);
       if (strFound) TRange.select();
    }
     }
     else if (navigator.appName=="Opera") {
      alert ("Opera browsers not supported, sorry...")
      return;
     }
     if (!strFound) alert ("String '"+str+"' not found!")
     return;
    }
    
  3. Use a knowledgebase extension that has built-in search function.

1

No, it is not possible. Joomla "Search module" search through content areas in CMS database. It does not search in a published article, on the browser side.

1

There seem to be a couple of Joomla modules which allow you to search for text within the same page using JavaScript.

Not sure if this is what you are looking for https://jdev.l-it.co.za/products/in-page-search-term-highlighter

This module basically lets you search for content within the same page you are on, similar to the CTRL+F browser search feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.