Bug 39216 - Add an item type dropdown filter to the OPAC main search
Summary: Add an item type dropdown filter to the OPAC main search
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-28 13:18 UTC by Laura Escamilla
Modified: 2025-05-19 17:18 UTC (History)
1 user (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Dropdown example image (162.38 KB, image/png)
2025-02-28 13:18 UTC, Laura Escamilla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laura Escamilla 2025-02-28 13:18:58 UTC
Created attachment 178820 [details]
Dropdown example image

Some libraries would like to have the option of filtering their searches by item type during their main search. I have attached an image as an example.
Comment 1 Sarah Cornell 2025-03-06 14:54:27 UTC
We are using the dropdown in the screenshot. It's convenient for patrons to be able to add these limits ahead of time even though they can also use the facets after they see the results.
Comment 2 Owen Leonard 2025-05-17 14:30:40 UTC
(In reply to Sarah Cornell from comment #1)
> We are using the dropdown in the screenshot.

Is it a customization you've added via plugin or JS? Or a customization your support company did for you?
Comment 3 Sarah Cornell 2025-05-19 17:18:49 UTC
It's this JS. Not sure which developer created it, but it was ByWater not library staff.  

//BEGIN Add Search Limits dropdown to Main Search Box opac-main.pl
$(document).ready(function() {

  // Append the dropdown to the search form if the element exists
  if ($("#opac-main-search .row.gx-2").length) {
    $("#opac-main-search .row.gx-2").append(`
      <div class="col-sm-auto order-2 order-sm-2">
        <select id='item_types' class='form-select'>
          <option value=''>All Items</option>
          <option id='book_search' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-itype%3AD1&limit=mc-itype%3AA&limit=mc-itype%3AD3&limit=mc-itype%3AB&limit=mc-itype%3AD7&limit=mc-itype%3AAN'>Books</option>
          <option id='audiobook_limit' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-itype%3AQ&limit=mc-itype%3AQ3'>Books on CD</option>
          <option id='dvdmovie_limit' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-itype%3AV&limit=mc-itype%3AV2&limit=mc-itype%3AVN'>DVDs</option>
          <option id='music_limit' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-itype%3AX'>Music CDs</option>
          <option id='largetype_limit' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-loc%3APBLP'>Large Print Books</option>
          <option id='digital_limit' value='http://portsmouth.bywatersolutions.com/cgi-bin/koha/opac-search.pl?&limit=mc-itype%3AY&limit=mc-itype%3AZ&limit=mc-itype%3AT&limit=mc-itype%3AJ'>Digital Content</option>
        </select>
      </div>
    `);
    console.log("Dropdown appended");
  } else {
    console.log("Could not find target element (#opac-main-search .row.gx-2)");
  }