New Items Pull Down in Koha 10


One thing that we get a lot of requests for in Koha is a list of links to new materials. I thought I might share with you all a little trick I just used to create such a list today.

In this case someone asked for a pull down menu of the newest items by item type. These tips will work (with a couple changes) for collection codes or shelving locations as well.

First, I want to make sure you’re aware that every link in Koha is a permanent link. This means if I do a search for everything of a specific item type sorted by the acquisitions date and bookmark that URL, whenever I click it I’ll see the newest items of that type on the first few pages of the results.

I took this knowledge and wrote a form takes this functionality in to consideration. It basically just does a search of your Koha catalog for a specific item type and sorts the results by acquisitions date.

So, the first thing I did was write a MySQL statement to generate a list of item types for me – why copy and paste when you can use the power of MySQL?

select concat('<option value=\"mc-itype:', itemtype, '\">',description,'</option>') from itemtypes

The above looks at the itemtypes table and slaps the necessary HTML around each item type for me. I then exported that to CSV and opened it in my text editor and added the other parts of the form.

<p><strong>New Items</strong></p>
<p><form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl">
<input name="idx" value="kw" type="hidden">
<input name="sort_by" value="acqdate_dsc" type="hidden">
<input name="do" value="OK" type="hidden">
<select name="limit" onchange="this.form.submit()">
<option>-- Please choose --</option>
<option value="mc-itype:BOOK">Book</option>
<option value="mc-itype:BOOKCD">Book on CD</option>
<option value="mc-itype:DVD">DVD</option>
<option value="mc-itype:LRG_PRINT">Large print book</option>
<option value="mc-itype:MAGAZINE">Magazine</option>
<option value="mc-itype:NEWSPAPER">Newspaper</option>
<option value="mc-itype:VIDEO">Videocassette</option>
</select>
</form>
</p>

Now, what does all of that mean?

The important bits are these:

First the starting of the form.

<p><form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl">

This tells the browser to take any value selected and put it at the end of this http://YOURSITE/cgi-bin/koha/opac-search.pl

Next, there is a hidden value that is telling the search to sort by acquisitions date descending (newest items at the top):

<input name="sort_by" value="acqdate_dsc" type="hidden">

And finally you have an option for each item type you want people to search.

<option value=”mc-itype:BOOK”>Book</option>

These options each include the string “mc-itype:” which tells Koha to do an item type search.

Once you have all of that in place you can copy and paste the form to somewhere on your OPAC. The Farmington Libraries have a great example of this on the left hand side of their OPAC if you’d like to see it in action.


Leave a comment

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.

10 thoughts on “New Items Pull Down in Koha

  • Chris

    In 3.8.x you can do this with the reports svc, which if you make a report public can hand you back the html (or json) and jquery can build your dropdown on the fly.

    Change an itemtype description, or add a new one, et voila its on the OPAC already.

  • Jane Cothron

    Nicole–
    How would I change this to search for an authorized value of LOC (location) instead of searching by item type?
    Thanks–
    Jane

  • Manny

    Good day Nicole,

    This was very helpful for us but I’m having problem running it with biblio records with multiple items like periodicals. It only referes to the first item and not the recent item. Hope you can help us on this.

    Salamat,
    Manny

  • Sean

    How would you go about limiting the number of results returned? Say, 100. Rather than every result for that itype (eg. books returns all books, sorted by acq date. That’s a lot of results).

    • Nicole C. Engard Post author

      Right now I don’t think there is a way to limit the number of results returned by Zebra (the search engine). It might be a question for the community to see if there is a filter I don’t know about.

  • jennyschmidt`

    Is there a way to combine two mc-itype codes in one option value? I’ll test it out but if you know, that’d be great. Thanks. jen.