Skip to main content
ExLibris
  • Subscribe by RSS
  • ExLibris Dev

    Make a Search Box using Primo Deep Links (dlSearch.do)

    • Article Type: General
    • Product: Primo
    • Product Version: 4

    Desired Outcome Goal:
    Make a Search Box using Primo Deep Links (dlSearch.do) that can be embedded on a Library's main web page.
    Direct linking to Primo's search.do function from outside sites (such as from a search box on a Library's main web page) is neither recommended nor supported. It can only be used from the Primo user interface.

    Procedure:
    1. Copy and paste the HTML below into an *.html file on your desktop (or web server...)
    For example, save it to a file called searchbox.html .

    2. To test it, open the html file in your browser, or if on a web server, go to: http://{__web_server__}/{__path__}/searchbox.html

    3. HTML
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Script that converts the query string into dlSearch.do valid parameter -->
    <script type="text/javascript">
    function searchPrimo() {
    document.getElementById("primoQuery").value = "any,contains," + document.getElementById("primoQueryTemp").value.replace(/[,]/g, " ");
    document.forms["searchForm"].submit();
    }
    </script>
    </head>
    <body>
    <form id="simple" name="searchForm" method="get" target="_self" action="http://<HOST_NAME>/primo_library/libweb/action/dlSearch.do" enctype="application/x-www-form-urlencoded; charset=utf-8" onsubmit="searchPrimo()">
    <!-- Customizable Parameters -->
    <input type="hidden" name="institution" value="<INSTITUTION CODE>">
    <input type="hidden" name="vid" value="<VIEW CODE>">
    <input type="hidden" name="tab" value="<TAB CODE>">
    <input type="hidden" name="search_scope" value="<SCOPE NAME>">
    <input type="hidden" name="mode" value="Basic">

    <!-- Fixed parameters -->
    <input type="hidden" name="displayMode" value="full">
    <input type="hidden" name="bulkSize" value="<RECORDS PER PAGE, e.g. 10>">
    <input type="hidden" name="highlight" value="true">
    <input type="hidden" name="dum" value="true">
    <input type="hidden" name="query" id="primoQuery">
    <input type="hidden" name="displayField" value="all">

    <!-- Enable this if "Expand My Results" is enabled by default in Views Wizard -->
    <input type="hidden" name="pcAvailabiltyMode" value="true">

    <input type="text" id="primoQueryTemp" value="" size="35">

    <!-- Search Button -->
    <input id="go" title="Search" onclick="searchPrimo()" type="button" value="Search" alt="Search" style="height: 22px; font-size: 12px; font-weight: bold; background: #DE6E17; color: #ffffff; border: 1px solid;">
    </form>
    </body>
    </html>

    Additional Information

    * Direct linking to Primo's search.do function from sites outside of Primo is neither recommended nor supported.
    * Primo TotalCare customers may submit a case to request the Back Office codes needed for the above example.
    * Values for form action, Institution, vid, search_scope, tab should be replaced (including the { } braces) with customer-specific values for these codes.
    * NOTE that the tab value MUST be in lowercase, even if the tab value in Primo is upper or mixed case.
    * Query parameter is often problematic because it requires 3 arguments that are separated by commas.
    An HTML form does not handle this natively, which is why the extra javascript function (validateForm()) is needed.
    * ValidateForm function checks for empty searchterm and adds 'any,contains,' arguments to query parameter.
    * The template in this article only represents a simple working example. The HTML, form, javascript, and Deep Link parameters may be customized as needed, including adding or removing Deep Link parameters.
    * To make "expand beyond library collections" enabled, add this parameter to the form: <input type="hidden" name="pcAvailabiltyMode" value="true">
    * <input type="hidden" id="bulkSize" name="bulkSize" value="10"/> allows the library to set a different default number of results returned form the default defined in the Views Wizard.
    Add this to the "Customizable Parameters" section (optional).
    * Additional functionality and parameters for Primo Deep Links are documented in Ex Libris Developer Network: https://developers.exlibrisgroup.com/primo/apis/deeplinks/brief

    Category: Embedding Primo Search box


    • Article last edited: 3/3/2015
    //doorbell.io feedback widged