<<

NAME

C4::ShelfBrowser - functions that deal with the shelf browser feature found in the OPAC.

SYNOPSIS

  use C4::ShelfBrowser;

DESCRIPTION

This module provides functions to get items nearby to another item, for use in the shelf browser function.

'Nearby' is controlled by a handful of system preferences that specify what to take into account.

FUNCTIONS

GetNearbyItems($itemnumber, [$num_each_side])

  $nearby = GetNearbyItems($itemnumber, [$num_each_side]);

  @items = @{ $nearby->{items} };

  foreach (@items) {
      # These won't format well like this, but here are the fields
          print $_->{title};
          print $_->{biblionumber};
          print $_->{itemnumber};
          print $_->{browser_normalized_upc};
          print $_->{browser_normalized_oclc};
          print $_->{browser_normalized_isbn};
  }

  # This is the information required to scroll the browser to the next left
  # or right set. Can be derived from next/prev, but it's here for convenience.
  print $nearby->{prev_item}{itemnumber};
  print $nearby->{next_item}{itemnumber};
  print $nearby->{prev_item}{biblionumber};
  print $nearby->{next_item}{biblionumber};

  # These will be undef if the values are not used to calculate the 
  # nearby items.
  print $nearby->{starting_homebranch}->{code};
  print $nearby->{starting_homebranch}->{description};
  print $nearby->{starting_location}->{code};
  print $nearby->{starting_location}->{description};
  print $nearby->{starting_ccode}->{code};
  print $nearby->{starting_ccode}->{description};

This finds the items that are nearby to the supplied item, and supplies those previous and next, along with the other useful information for displaying the shelf browser.

It automatically applies the following user preferences to work out how to calculate things: ShelfBrowserUsesLocation, ShelfBrowserUsesHomeBranch, ShelfBrowserUsesCcode.

The option $num_each_side value determines how many items will be fetched each side of the supplied item. Note that the item itself is the first entry in the 'next' set, and counts towards this limit (this is to keep the behaviour consistant with the code that this is a refactor of.) Default is 3.

This will throw an exception if something went wrong.

<<