Links to item in catalog

1 view
Skip to first unread message

Kevin Becker

unread,
May 1, 2008, 7:16:47 PM5/1/08
to Scriblio
Is it possible to automagically add a 'request this item' link in
Scriblio? If not, how can I link to the item record in our catalog?
I used the III opac importer to add several items to Scriblio, but
there's no link to the iii opac record. Any thoughts?

Casey Bisson

unread,
May 2, 2008, 8:59:29 AM5/2/08
to scri...@googlegroups.com

Yep.

Take a look at the example script here:
http://about.scriblio.net/wiki/scrib_availability

That script is what we use at Plymouth to connect the record in our
Scriblio instance to our III ILS. The main purpose is to show the
current location and availability of the items, but it also adds a few
links, including one to view the record and another to request it.

It's an ugly and sloppy bit of code, but near the bottom you'll see
this:

'<p><a href="'. $WPopac_ilsbase .'record='. $id .'"
rel="nofollow">View record in LOLA catalog</a> · <a href="'.
$WPopac_ilssso . urlencode($WPopac_ilsbase.'search/.b'.$id .'/.b'.
$id .'/1%2C432%2C432%2CB/request') .'" rel="nofollow">Request item</
a></p>'

That bit inserts both the links you're asking about, but I should
explain the variables:

$id is the III bib record ID
$WPopac_ilsbase is the base URL to the III web OPAC (mine is 'http://lola.plymouth.edu/')
$WPopac_ilssso is the URL to the single sign-on hack I wrote (not part
of Scriblio). You should probably ignore that and rewrite the code
like this:

'<p><a href="'. $WPopac_ilsbase .'record='. $id .'"
rel="nofollow">View record in LOLA catalog</a> · <a href="'.
$WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/1%2C432%2C432%2CB/
request' .'" rel="nofollow">Request item</a></p>'

Please write back to tell us how it works,

--Casey

Kevin Becker

unread,
May 3, 2008, 10:25:51 AM5/3/08
to Scriblio
I've seen that code before, but when I ran into a problem with it. I
create availability.php in the plugins folder, copy the code, and when
I activate it I get this:

Fatal error: Cannot redeclare scrib_availability() (previously
declared in /var/www/scriblio/wp-content/plugins/scriblio/scriblio.php:
1707) in /var/www/scriblio/wp-content/plugins/availability.php on line
45

I'm gonna try to find a workaround...

Kevin Becker

unread,
May 3, 2008, 10:33:04 AM5/3/08
to Scriblio
I replaced the old code with what you've posted above, so now the
error has moved to a different line. Thanks for explaining the
various functions- it makes it much more pleasant to work on.

Kevin Becker

unread,
May 3, 2008, 11:40:56 AM5/3/08
to Scriblio
After I commented out the availability section of scriblio.php, I got
rid of the above error. The links display properly, but unfortunately
they don't seem to link to a record yet.

Here's my site: http://airsatz.com/scriblio/?p=28

Here's my availability.php, if there are any glaring problems you'd
like to point out:

<?php
/*
Plugin Name: My Site Extras
Description: Local customizations for My Site
Author: Me.
Version: 1.0
Author URI: http://My_URL.com/
*/
function scrib_availability($id){

$id = substr($id, 2);

$WPopac_ilsbase = 'http://webcat.lcls.org/';

$raw = utf8_encode(file_get_contents($WPopac_ilsbase .'record='.
$id));

$temp = explode('</table>', $raw);

$availability = NULL;
foreach($temp as $tem){
$te = explode('bibItems">', $tem);
if($te[1]){
$availability = strip_tags(('<table>' . $te[1] . '</table>'),
'<table><tr><td><th>');
break;
}
}

foreach($temp as $tem){
$te = explode('bibHoldings">', $tem);
if($te[1]){
$holdings = strip_tags(('<table border = 0>' . str_replace("\n",
'', $te[1]) . '</table>'), '<table><tr><td><th><hr>');
break;
}
}

if($availability){
return($availability . '<p><a href="'. $WPopac_ilsbase .'record='.
$id .'" rel="nofollow">View record in LCLS catalog</a> · <a href="'.
$WPopac_ilssso . urlencode($WPopac_ilsbase.'search/.b'.$id .'/.b'.
$id .'/1%2C432%2C432%2CB/request') .'" rel="nofollow">Request item</
a></p>');
}else if($holdings){
return($holdings . '<p><a href="'. $WPopac_ilsbase .'record='.
$id .' rel="nofollow"">View record in LCLS catalog</a></p>');
}else{
return('<p><a href="'. $WPopac_ilsbase .'record='. $id .'"
rel="nofollow">View record in LCLS catalog</a> · <a href="'.
$WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/1%2C432%2C432%2CB/
request' .'" rel="nofollow">Request item</a></p>');
}
}
?>

Casey Bisson

unread,
May 3, 2008, 12:08:08 PM5/3/08
to scri...@googlegroups.com

I was just about to recommend commenting out the other function.

The scrib_availability function isn't supposed to get declared if
there's another one already declared, but it seems like your plugin is
getting loaded after Scriblio, causing the problem. I have another
solution to fix that and prevent it from causing difficulty later, but
at least you've worked around it for now.

I took a look at your catalog and found that the bibnumber for your
example record is:

1354026

But the bib number in Scriblio is:

354026

The number looks almost right, just missing the leading digit. What
_should_ be happening is that the record's full sourceid gets sent to
scrib_availability(), where this line of code trims the source ID
prefix off the front:

$id = substr($id, 2);

The prefix is supposed to be two characters. It hasn't yet mattered to
any production instance that I'm aware of, but you _can_ assign
different source id prefixes to different ILSs and build a union
catalog that way. The example code, however, ignores the prefix and
assumes all the records are from a single ILS. And that works if the
source id prefix is always exactly two characters long, but, well, is
your prefix two characters long?

If not, you've found a bug in Scriblio's UI and documentation that I
need to fix, but you can work around it in the short term in one of
two ways:

The preferred way is to reimport content using a two-character prefix
The quick way is to change the substring to only trim one char.

This prefix issue can be confusing for us III users, since all our bib
numbers are prefixed with "b", but this is a different prefix. You've
probably seen it, but I'm going to toss this screenshot out as a point
of reference:

http://flickr.com/photos/scriblio/1934135957/

Finally, I think there's a linebreak in your code that's turning into
a full <br> tag. That explains why the rel="nofollow" stuff is showing.

--Casey

Kevin Becker

unread,
May 3, 2008, 4:39:00 PM5/3/08
to Scriblio
Spot on. I re-imported the records and the link to the iii opac
worked just fine. For some reason the 'request this item' link is
sending the bib number twice, which is causing problems. More to
come....

Casey Bisson

unread,
May 4, 2008, 10:49:23 AM5/4/08
to scri...@googlegroups.com

The III URL syntax can be awkward that way.

I think you've got a line break in the "request this item" link too,
but it's being URL encoded and is hard to see. But that won't fix the
problem causing it to fail. We don't use that feature now and I can't
guarantee that my code works as it should, so I took a deeper look.

Starting with this record in your ILS:
http://webcat.lcls.org/record=1354076

We get this URL to request the item:
http://webcat.lcls.org/search/.b1354076/.b1354076/1%2C1%2C1%2CB/
request~b1354076

In that URL, we discover that the bibnumber actually appears three
times. Here it is broken down:

http://{ILS hostname}/search/.b{bibnumber}/.b{bibnumber}/1%2C1%2C1%2CB/
request~b{bibnumber}

I think my example code worked on my ILS when I wrote it, but it's
clear that your ILS is expecting something slightly different.
Something like this should work for you:

$WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/1%2C432%2C432%2CB/

request'. $id

--Casey

Kevin Becker

unread,
May 22, 2008, 3:28:41 PM5/22/08
to Scriblio
I'm still struggling with the item request. I added the code you
suggested, but I can't figure out what else is needed. Here's my
plugin:

<?php
/*
Plugin Name: Availability
Description: Webcat Location & Availability
urlencode($WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/
1%2C432%2C432%2CB/request'. $id) .'" rel="nofollow">Request item</a></
p>');
}else if($holdings){
return($holdings . '<p><a href="'.
$WPopac_ilsbase .'record='. $id .'" rel="nofollow">View record in LCLS
catalog</a></p>');
}else{
return('<p><a href="'. $WPopac_ilsbase .'record='.
$id .'" rel="nofollow">View record in LCLS catalog</a></p>');
}
}

?>

And here's an example link: http://airsatz.com/scriblio/archives/2708

Casey Bisson

unread,
May 23, 2008, 1:51:06 PM5/23/08
to scri...@googlegroups.com

The $WPopac_ilssso thing is getting in your way. It's irrelevant in your case, but my example is misleading you.

You don't need to URL encode the request URL in your situation, so the line you have that looks like this:

 <a href="'. $WPopac_ilssso . urlencode($WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/1%2C432%2C432%2CB/request'. $id) .'" rel="nofollow">Request item</a></p>');

Should probably be written like this:

 <a href="'. $WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/1%2C432%2C432%2CB/request'. $id .'" rel="nofollow">Request item</a></p>');

If that works, I'd like to post your plugin as an example, as it's more relevant than mine. Would you mind?

--Casey


On May 22, 2008, at 3:28 PM, Kevin Becker wrote:


I'm still struggling with the item request.  I added the code you
suggested, but I can't figure out what else is needed.  Here's my
plugin:

 <a href="'. $WPopac_ilssso .
urlencode($WPopac_ilsbase.'search/.b'.$id .'/.b'.$id .'/
1%2C432%2C432%2CB/request'. $id) .'" rel="nofollow">Request item</a></
p>');

Kevin Becker

unread,
May 27, 2008, 10:22:11 AM5/27/08
to Scriblio
That did the trick. Here's my new availability.php:

<?php
/*
Plugin Name: Availability
Description: Webcat Holdings & Availability
catalog</a> · <a href="'. $WPopac_ilsbase.'search/.b'.$id .'/.b'.
$id .'/1%2C432%2C432%2CB/request'. $id .'" rel="nofollow">Request
item</a></p>');
}else if($holdings){
return($holdings . '<p><a href="'.
$WPopac_ilsbase .'record='. $id .'" rel="nofollow">View record in LCLS
catalog</a></p>');
}else{
return('<p><a href="'. $WPopac_ilsbase .'record='.
$id .'" rel="nofollow">View record in LCLS catalog</a></p>');
}
}

?>

and a working example:
http://airsatz.com/scriblio/archives/1955

Good work!

Casey Bisson

unread,
May 27, 2008, 12:00:17 PM5/27/08
to scri...@googlegroups.com

Kevin,

This is great. Glad to hear it's working.

Can you send the plugin to me off list as an attachment? The mail list
software tortures code too much to rely on.

Also, don't hesitate to put your own name and URL in the plugin header.

--Casey

Reply all
Reply to author
Forward
0 new messages