User Tools

Site Tools


en:user:gs3_sample_interface_modifications

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
en:user:gs3_sample_interface_modifications [2019/10/21 20:58] – [Changing the collection description] kjdonen:user:gs3_sample_interface_modifications [2019/10/21 22:28] – [Changing the collection description] kjdon
Line 20: Line 20:
 <gslib> elements are shortcuts to predefined templates, and can be found in web/interfaces/default/transform/gslib.xsl. See the [[en:user:gslib|gslib page]] for more details. <gslib> elements are shortcuts to predefined templates, and can be found in web/interfaces/default/transform/gslib.xsl. See the [[en:user:gslib|gslib page]] for more details.
  
-Lets leave the collection description displayed as is, but output "This collection contains X documents, and was last built on Y".+This template basically outputs the collection'description displayItem. Lets leave that displayed as is, but also output "This collection contains X documents, and was last built on Y".
  
 We can redefine the template as: We can redefine the template as:
Line 36: Line 36:
 The buildDate metadata element is a timestamp, so is not user friendly. We can use one of our utility functions to format it. The buildDate metadata element is a timestamp, so is not user friendly. We can use one of our utility functions to format it.
 Utility functions are defined in src/java/org/greenstone/gsdl3/util/XSLTUtil.java. Utility functions are defined in src/java/org/greenstone/gsdl3/util/XSLTUtil.java.
 +In this case, we are formatting the timestamp as a date (the second 0). We could also format it as 'days ago' (using 3 instead of 0):
 +<code>
 +The collection contains <gslib:collectionMeta name="numDocs"/> documents, and was last 
 +   built <xsl:value-of select="util:formatTimeStamp($raw_date, 0, 3, /page/@lang)"/> days ago.
 +</code>
 +
 +If we want this text to be displayed in a language dependent manner, then we need to define it in the properties file, (and translate it in the appropriate language properties file), and retrieve it from there.
 +
 +The default interface has these two statements already defined (in web/WEB-INF/classes/interface_default.properties):
 +<code>
 +about.standarddescriptiondays=This collection contains {0-numdocs} documents and was last built {1-numdays} days ago.
 +about.standarddescriptiondate=This collection contains {0-numdocs} documents and was last built on {1-date}.
 +</code>
 +
 +To call them, we need to define variables for the arguments, and then pass them in as a ; separated string.
 +<code>
 +<xsl:variable name="raw_date"><gslib:collectionMeta name="buildDate"/></xsl:variable>
 +<xsl:variable name="formatted_date"><xsl:value-of select="util:formatTimeStamp($raw_date, 0, 3, /page/@lang)"/></xsl:variable>
 +<xsl:variable name="numdocs"><gslib:collectionMeta name="numDocs"/></xsl:variable>
 +<p><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.standarddescriptiondays', concat($numdocs, ';', $formatted_date))"/></p>
 +</code>
 +
 +If we wanted to use this technique, but want to define our own text just for the collection, we can add an interface_custom.propeties file into web/sites/localsite/collect/coll-name/resources folder.
 +Define the property there, eg:
 +<code>
 +descriptionextra=This very awesome collection was last built {0-days} ago, and contains {1-numdocs} manuscripts.
 +</code>
 +
 +Then we use a similar utility function call that will look for the key in the custom file instead of the standard file:
 +<code>
 +<xsl:value-of select="util:getCollectionText('lucene-jdbm-demo', $site_name, /page/@lang, 'descriptionextra', concat($formatted_date, ';', $numdocs))"/>
 +</code>
 +Note we have changed the order in which we use the arguments, so we need to change the order we pass them in.
  
 ==== Total documents in library ==== ==== Total documents in library ====
en/user/gs3_sample_interface_modifications.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1