User Tools

Site Tools


en:user:berry_baskets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:user:berry_baskets [2019/10/02 01:39] – [Metadata] kjdonen:user:berry_baskets [2019/10/02 01:51] – [Using dc.Title instead of Title in Berry Basket display] kjdon
Line 36: Line 36:
 If we have a collection that doesn't have Title metadata (eg from a CSV spreadsheet), we can modify the code to display dc.Title instead. If we have a collection that doesn't have Title metadata (eg from a CSV spreadsheet), we can modify the code to display dc.Title instead.
  
-1. Edit web/sites/localsite/siteConfig.xml and add dc.Title into the metadataList:+1. Edit web/sites/localsite/siteConfig.xml and add dc.Title into the BerryBasket service metadataList:
 <code> <code>
 <serviceRack name="BerryBaskets"> <serviceRack name="BerryBaskets">
Line 68: Line 68:
 } }
 </code> </code>
 +
 +This will now display dc.Title instead of Title for the title link to the document in the full view.
 +However, as dc.Title is not defined as one of the standard metadatas, it also gets added to the end of the display. To prevent this, either add it to the default_metas list at the top of the file, or modify generateDocDisplay further.
 +<code>
 +Replace:
 +for (var metaItem in doc) {
 +  if ( !default_metas.includes(metaItem)){
 +     metadata += " "+metaItem+": "+ doc[metaItem]+" ";
 +  }
 +}
 +
 +with:
 +for (var metaItem in doc) {
 +  if ( !default_metas.includes(metaItem) && metaItem != 'dc.Title'){
 +     metadata += " "+metaItem+": "+ doc[metaItem]+" ";
 +  }
 +}
 +</code>
 +
 +In the text and email view, all metadata is displayed in a list: First the hard-wired ones, then any that are not in the default list. So the dc.Title metadata just gets added to the list. If you added dc.Title to default_metas list as mentioned above, then you need to manually add it to the display to get it to appear.
 +
 +For example, in populateUrlsAndMetadata(), add in the following:
 +<code>
 +if (doc['dc.Title']) {
 +  metadata += "dc.Title: "+doc['dc.Title']+"\n";
 +}
 +</code>
 +
  
  
en/user/berry_baskets.txt · Last modified: 2023/07/24 01:44 by kjdon