[OPEN-ILS-GENERAL] Adding more than one subfield in rdetail_result.xml

Dan Scott dan at coffeecode.net
Wed Feb 29 11:05:48 EST 2012


On Wed, Feb 29, 2012 at 10:09 AM, Michael Schell
<MSchell at forterie.library.on.ca> wrote:
> Hi All,
>
> I am trying to modify rdetail_result.xml to show the 245 tag with more than
> one subfield.
>
> I can get it to show a single subfield easily like this:
>
> <td class="title" type='opac/slot-data' query='datafield[tag=245]
> subfield[code=a]'></td>
>
> but is there a way to tell this line to output subfield[code=a+b]

Assuming you don't want to show every field in the 245, but just a
select number, a Firefox 10-safe[1] way of doing this is like so[2]:

<tr class='hide_me' id='tag020'>
  <td nowrap='nowrap' class='rdetail_desc'>&common.isbn;</td>
  <td type='opac/slot-data' query='datafield[tag="020"]' class='rdetail_item'>
    <script type='opac/slot-format'><![CDATA[
    var output = '';
    dojo.query('subfield', item).forEach(function(item) {
      if (item.getAttribute("code") == 'a' ||
item.getAttribute("code") == 'z') {
        dojo.query('#tag020').removeClass('hide_me');
        var isbn = getISBN(BT.textContent(item) + '');
        output += '<span>' + isbn + '</span><br/>';
      }
    });
    return output;
    ]]></script>
  </td>
 </tr>


In essence:

a. Grab the full tag.
b. Declare an output variable.
c. Issue another dojo.query() call over the contents of the tag to
pull out the subfields.
d. Check the subfield codes to ensure they match what you want.
e.Use BT.textContent() to extract the text value of the subfield. (For
a title or most other cases, you won't want the getISBN() cleanup
call). Add that to your output variable.
f. Return the output variable outside of the dojo.query() scope to
fill in the contents of the table cell (or whatever scope you're in).

1. http://evergreen-ils.org/blog/?p=729
2. http://goo.gl/TqaV9


More information about the Open-ils-general mailing list