Skip to Questions

Guide FAQ - Your LibGuides v1 Questions. Answered!

Q

Can I add a search box that only searches within one LibGuide?

Last Updated: Dec 10, 2012  |  3471 Views

Was this helpful? 10   1
A

Answer

Sure can!

  1. Add a Rich Text box to your page.
  2. Click add text then click the Plain Text Editor tab (this step is very important).
  3. Copy and paste this code into the Plain Text Editor:

    <script type="text/javascript">
    function search() {
    var iid = myIID;
    var guide_id = myPID;
    var search_val = document.getElementById('txt_search').value;
    var url = 'search.php?iid=' + iid + '&c=0&gid=0&pid=' + guide_id + '&search=' + search_val;

    window.location.href = url;

    return false;
    }
    </script>
    <form id="frm_search" name="frm_search" onsubmit="return search();">
    Search this guide
    <input id="txt_search" name="txt_search" type="text" />
    <input onclick="search();" value="Go" type="button" />
    </form>
  4. Click Save Changes.

That's all there is to it! You now have a search box on your page that will search just that one guide.

Answered by Anna BurkeBookmark and Share

Other Answers / Comments (16)

  1. Hi - is there any way to modify this so it searches the one guide its embedded in, plus one other guide? The reason is, I have a second guide that we've created separately and linked to the main guide. I'd like to be able to search both guides together from the main guide.
    by Chris on Jul 22, 2011.
  2. Hi Chris - Based on the way the LibGuides search operates, it's not possible to create a search that searches only in 2 guides. CampusGuides can achieve this (by creating a "group" that consists of those 2 guides, then searching the group), but the LibGuides search can't combine & search separate guides on the fly. Sorry about that!
    by Sarah Pawlek on Jul 22, 2011.
  3. I inserted this code under one tab in a tabbed box I put on one of my guides and while it does a fine job creating the box in the tab I specified, the search never returns any results (which words are entered does not seem to matter). For that matter, putting the code all by itself in a new Rich Text box on my guide doesn't seem to return results either. Any suggestions?
    by Scott Kaihoi on Mar 21, 2012.
  4. Hi Scott - did you add the code to a page that is published? Did you publish that guide today? If the guide isn't published, that means it hasn't been indexed by our indexer yet, so the search will not work. Indexing takes place each night, so if you just published it today, the search will not return results until tomorrow, after it's been indexed. If neither of those is the case, please let us know at support@springshare.com. :)
    by Anna Burke on Mar 21, 2012.
  5. It is an unpublished guide, as a matter of fact. That would be the problem. Thanks.
    by Scott Kaihoi on Mar 21, 2012.
  6. Can the above code be adapted to search a single guide - but not the current guide where the code is located? I have two interrelated guides where it would be helpful for patrons to be able to do a quick search of the other guide. Thanks.
    by Alisha on Jan 22, 2013.
  7. Good question, Alisha. The answer is Yes. Just replace MyPID in the code with the PID of the guide you want to search.
    - Ken
    by Ken Liss on Jan 22, 2013.
  8. Hi. I used this search box and it works. But is it possible to highlight the words that have been searched ? Otherwise, the box doesn't seem useful. Thanks.
    by Anne-Gaëlle on Apr 17, 2013.
  9. Hi Anne-Gaëlle-
    Unfortunately the highlight option caused all sorts of script issues with the browsers so we had to turn it off.
    by Michelle Lustig on Apr 17, 2013.
  10. I'm also having the problem where the search doesn't occur. The guide I am using is already published. Any ideas?
    by Lori Harris on Jul 01, 2014.
  11. Hi Lori - when was it published? If it was published today, then it hasn't been indexed yet, so the search wouldn't work.

    - Anna :)
    by Anna Burke on Jul 01, 2014.
  12. I have pages of links inside simple web link content boxes. When I do a search of the guide the results only shows the tab level (page level). I want results that drill down more. What good is the individual page? At the very least it should show all content boxes that have that specific keyword. How can this be done?
    by Kendrick Keeton on Jul 15, 2014.
  13. My question is the same as Q.12, is it possible for teh search to drill down further ? As far as I know there has been no reply to that question. I am asking because one or our teachers would like the students to be able to use this for a more targeted search.
    by naomi on Mar 10, 2015.
  14. Hello, Naomi!

    No, I'm afraid that it is not possible for the search to drill down farther.

    In LibGuides v2, search results are presented with "facets" on the side so that the results can be narrowed by guide, asset type, tag, and other parameters.

    Hope this helps! :)

    Best,
    -Cindi
    by Cindi Blyberg on Mar 11, 2015.
  15. I've embedded the above code as per the instructions and I'm getting a 'Error(404)' message when I run the search.

    The page type is 'General Purpose', and was published as 'private' about a week or so ago.

    I'm not sure whether I should be replacing any of the code with metadata specific to my libguide, such as ID numbers, URLs, etc.

    Thanks in advance,

    Martin
    by Martin on Jan 20, 2016.
  16. Hi Martin,

    It appears your LibGuides site (http://libguides.csu.edu.au/) is using LibGuides v2, but the code we've provided here will only work with LibGuides v1. That's why you're getting a 404 error when attempting to search using this code.

    We don't currently have the ability to scope a search to an individual guide in LibGuides v2 yet. However, you can create a Search widget (under Tools > Widgets) that can search all of your guides.

    I hope this helps. For our LibGuides v2 documentation, please be sure to go to http://support.springshare.com. If you have any other questions, please do let us know at http://ask.springshare.com.

    Best,
    -Tim Bowersox
    by Tim Bowersox on Jan 21, 2016.

Need Help?

This site contains FAQs for LibGuides v1 only.

LibGuides v2 Documentation
(You must have a LibApps account to access that site.)

Or click HELP in the orange command bar of your v2 system.

Support:

Follow LibGuidesFAQ on Twitter Follow us on Twitter!
 Your questions, answered!

Browse by Popular Topics

Accounts  –  Admin Area  –  API / Widgets  –  Boxes  –  Catalog / Database Integration  –  CSS  –  Customization  –  E-Reserves  –  Embedding Objects  –  General System Questions  –  Group Management  –  Guides  –  Holiday Closures  –  How To...  –  Images  –  LibGuides CMS  –  Links  –  Mobile  –  Pages / Tabs  –  Profiles  –  RSS  –  Search  –  Security  –  Statistics  –  Subject Categories  –  Survey/Form Tool  –  System Administrators  –  Tags  –  Webinar  
View All Topics

Related content from Springshare v1 Help