[Koha-patches] [PATCH] If itemnumber is sent to catalogue/moredetail.pl use it

Galen Charlton galen.charlton at liblime.com
Thu Aug 28 17:17:03 CEST 2008


Hi Michael,

On Wed, Aug 27, 2008 at 9:46 AM, Michael Hafen <mdhafen at tech.washk12.org> wrote:
> Would help if I sent this to the list, Sorry Galen.
>
> I'll attach a new patch.  The lines that are failing there are from a
> different patch of mine.  I'll have to watch out for that in the future.

When I tested this patch, I found that it didn't work for me.
Specifically, when I displayed a bib that had three items and used the
itemnumber parameter to restrict the view to just one of them, the
bibliographic portion of the page was displayed, but not the item.
The Apache log contained the following error:

moredetail.pl: PARAM:LOOP:next_loop:hash pointer was expected but not
found at /usr/local/lib/perl/5.8.8/HTML/Template/Pro.pm line 191.,

It looks like H::T::Pro does not like it when an array of hashrefs
contains undef entries.

Rather than undef'ing the items you don't want, I suggest filtering them, e.g.:

+if ($itemnumber) {
+    my @selected_items = ();
+    foreach my $item (@items) {
+        push @selected_tems, $item if $item->{'itemnumber'} == $itemnumber;
     }
+    @items = @selected_items;
+}
+foreach my $item (@items){

Of course, that is inefficient for a bib that has a lot of items, as
the code is retrieving all of them from the database but throws away
most of the results, so an even better approach would be to retrieve
just the desired item.  On the UI front, there should also be some
indication that only one item is being displayed, and that the bib may
have more - possibly something like adding a "only item XXX is
displayed, click to see all items" link if the itemnumber parameter is
used and the bib has more than one item.

I do like the idea being able to restrict the circ items list to just
the desired one, so I am very interested in seeing some follow-up
patches.

Regards,

Galen
-- 
Galen Charlton
VP, Research & Development, LibLime
galen.charlton at liblime.com
p: 1-888-564-2457 x709
skype: gmcharlt



More information about the Koha-patches mailing list