User Tools

Site Tools


en:user:interfaces

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:interfaces [2019/09/22 23:24] kjdonen:user:interfaces [2019/09/23 00:02] – [How to change just one template] kjdon
Line 42: Line 42:
 before transformation by a stylesheet. This shows you the XML page source. It before transformation by a stylesheet. This shows you the XML page source. It
 can be useful when you are trying to write some new XSLT statements. can be useful when you are trying to write some new XSLT statements.
 +
 +==== How to change just one template ====
 +
 +You might like to make changes to the interface, but restrict them to a subset of the library. There are different ways to change a template.
 +For example, suppose we wanted to change what gets displayed on the about page for the collection description. If we look at the transform/pages/about.xsl, we find some templates:
 +<code>
 +<xsl:template match="/page">
 +....
 +   <xsl:call-template name="coll-description"/>
 +</xsl:template>
 +
 +<xsl:template name="coll-description">
 +  <gslib:collectionDescriptionTextAndServicesLinks/>
 +</xsl:template>
 +</code>
 +
 +We might decide that we don't want the default behaviour for the coll-description template and we want to change it.
 +
 +    - Edit the XSL file in web/interfaces/default/transform - if we edit the template directly in the main pages/about.xsl file, then the change will apply to all collections in our library.
 +    - Edit the XSL file in web/sites/<sitename>/transform - if we have multiple sites, we can make a new pages/about.xsl in the site's transform folder, and it will apply to only those collections in that site.
 +    - Edit the XSL in web/collect/<collname>/transform - we can make a new pages/about.xsl file in the collection's transform folder. Any changes we make here will only affect this collection.
 +
 +The new about.xsl file doesn't have to implement everything in the old version. You can add in only the templates that you want to change.
 +
 +For example, this might be the collection's about.xsl. We are only changing 1 template. The rest of the about page templates will come from the defualt XSL file: web/interfaces/default/transform/pages/about.xsl,
 +<code>
 +<?xml version="1.0" encoding="ISO-8859-1"?>
 +<xsl:stylesheet version="1.0"
 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 + xmlns:java="http://xml.apache.org/xslt/java"
 + xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
 + xmlns:gslib="http://www.greenstone.org/skinning"
 + extension-element-prefixes="java util"
 + exclude-result-prefixes="java util">
 +
 +
 +  <xsl:template name="coll-description">
 +    <xsl:value-of select="/page/pageResponse/collection/displayItemList/
 +displayItem[@name='description']" disable-output-escaping="yes"/>
 +   <h4>This collection has <xsl:value-of select="/page/pageResponse/collection/
 +metadataList/metadata[@name='numDocs']"/> docs.</h4>
 + </xsl:template>
 +
 +</xsl:stylesheet>
 +</code>
  
 ==== Changing the interface language==== ==== Changing the interface language====
en/user/interfaces.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1