User Tools

Site Tools


newdevs:code:add-subfield-to-record-display

Adding a Subfield to the Record Display Fields

Note: These instructions assume you are making a local change, and not one you intend to submit to the community. They could be adapted or expanded so that these changes could be included in a patch.

In the OPAC

1. Figure out the attribute you need to alter.

In this example, we’re looking at adding subfield f from MARC tag 300 to the physical description in the record summary. Thie physical description is defined in Open-ILS\src\templates-bootstrap\opac\parts\record\summary.tt2

                        	<li id='rdetail_phys_desc'>
                            	<strong class='rdetail_label'>[% l("Physical Description:") %]</strong>
                            	<span class='rdetail_value' highlighted='true'>[%
                                	filtered_hl_phys_desc.join('<br/>') %]</span>
                        	</li>
                        	[%- ELSIF attrs.phys_desc %]
                        	<li id='rdetail_phys_desc'>
                            	<strong class='rdetail_label'>[% l("Physical Description:") %]</strong>
                            	<span class='rdetail_value'>[% attrs.phys_desc | html %]</span>
                        	</li>

The OPAC is looking for the attribute “phys_desc” to define the value of the Physical Description.

2. Change the configuration of the attribute.

Configuration for display fields can be found in this file:

Open-ILS\src\templates-bootstrap\opac\parts\misc_util.tt2

If we search this file for “phys_desc” we find this clause:

    	phys_content = [];
    	FOR sub IN xml.findnodes(
        	'//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
    	);
        	phys_content.push(sub.textContent);
    	END;
    	args.phys_desc = phys_content.join(" ");

What you end up changing will depend on how the attribute is defined. In this case, we can just add the subfield so that it appears like the others listed here, like so:

    	phys_content = [];
    	FOR sub IN xml.findnodes(
        	'//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e" or @code="f"]'
    	);
        	phys_content.push(sub.textContent);
    	END;
    	args.phys_desc = phys_content.join(" ");

Subfield f should now display in the OPAC. A more complex attribute may require more testing.

In the Staff Catalog

1. Figure out the metabib field for the attribute you want to alter

You can confirm the metabib field that is being consulted by looking at the code in this file: Open-ILS\src\eg2\src\app\staff\catalog\result\record.component.html

Again, we’ll be looking at adding subfield f from tag 300 to the Physical Description (Phys. Description) in the Angular catalog search results in this example. When searching the file for “physical” we find the code that defines the value:

          	<ng-container *ngIf="summary.display.physical_description">
            	<!-- [].concat() to avoid modifying the summary arrays -->
            	<div class="pb-1" i18n>Phys. Desc.:
              	<eg-bib-display-field [summary]="summary"
                	field="physical_description" joiner=","></eg-bib-display-field>
            	</div>
          	</ng-container>

So the metabib field we’ll be looking at is “physical_description”

2. Check the format for the metabib field

In the GUI under Server Administration > MARC Search Facets/ Field or in the database in the config.metabib_field table, look for the entry with the name that matches what you found in step 1.

In this case, the format is “mods33.” If it was “marcxml”, we could alter the XPATH to include the code we want to display.

a. (For format type “marcxml” only) Change the XPATH

Add the subfield you want to display to the XPATH. See other marcxml entries for guidance on what this should look like.

b. (For MODS formats only). Alter the stylesheet for the version of MODS that corresponds to the format of the entry you want to change.

i. In the database, look for the name that matches the format of the entry you want to change in the config.xml_transform table. In this case, we’re looking at mods33.

ii. Look at the contents of the xslt field. It may be easiest to copy the text and paste it into a text editing program

iii. Look for the tag you want to add the subfield to. In this example, we find the following when searching for “300”:

                    	</xsl:for-each>
                    	<xsl:for-each select="marc:datafield[@tag=300]">
                            	<extent>
                                    	<xsl:call-template name="subfieldSelect">
                                            	<xsl:with-param name="codes">abce</xsl:with-param>
                                    	</xsl:call-template>
                            	</extent>
                    	</xsl:for-each>

The following change is enough to make sure subfield f is consulted:

                    	</xsl:for-each>
                    	<xsl:for-each select="marc:datafield[@tag=300]">
                            	<extent>
                                    	<xsl:call-template name="subfieldSelect">
                                            	<xsl:with-param name="codes">abcef</xsl:with-param>
                                    	</xsl:call-template>
                            	</extent>
                    	</xsl:for-each>

Note: You may want to add a comment to indicate this was added as a customization.

If you made the change in an outside text editing program, you can update the row with your changes.

3. Reingest affected records

To make sure all records get the change, you’ll want to run a partial reingest.

This query will reingest all affected records for our example. It may take a while to run depending on how many records are affected.

SELECT metabib.reingest_metabib_field_entries(id) FROM biblio.record_entry WHERE id in
(SELECT
mrfr.record
FROM metabib.real_full_rec mrfr
JOIN biblio.record_entry bre ON mrfr.record = bre.id
WHERE mrfr.tag = '300' AND mrfr.subfield = 'f'
and bre.deleted = FALSE);
newdevs/code/add-subfield-to-record-display.txt · Last modified: 2023/06/13 15:37 by jventuro

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.