User Tools

Site Tools


en:user:gs3_sample_format_statements

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_format_statements [2016/05/26 01:06] – [Sample Greenstone3 Format Statements] kjdonen:user:gs3_sample_format_statements [2016/09/26 22:51] – [Linking metadata to a search] kjdon
Line 152: Line 152:
 } }
 </code> </code>
 +
 +
 +===== Linking metadata to a search =====
 +
 +How to link metadata values to a search for that value.
 +For example, say a document has several authors, stored as dc.Creator metadata. You can display a list of the authors, each one linked to a search of the dc.Creator index for that author.
 +
 +Collection setup:
 +  * dc.Creator metadata will need to be assigned to the documents
 +  * You need to add a search index on dc.Creator metadata
 +  * Build the collection
 +
 +You will need to find out the shortname for the dc.Creator index. You can look in web/sites/localsite/collect/<your-coll-name>/index/buildConfig.xml. Look for the section like:
 +<code>
 +<indexList>
 +  <index name="text" shortname="TX" />
 +  <index name="dc.Title,ex.dc.Title,Title" shortname="TI" />
 +  <index name="dc.Creator" shortname="CR" />
 +</indexList>
 +</code>
 +You can see from this example that the dc.Creator index got the shortname "CR". You will need this shortname to construct the search URL.
 +
 +
 +Next you need to modify your format statement to add in the search links. If you want these links to appear on the document page, select the "display" format item. (If you wanted them in search results, or on classifier pages, select the "search/browse/CLx" format items)
 +
 +The default XML for the display format item contains several commented out templates. Say you have simple documents (ie ones with no internal structure eg images), you can add the links to the "documentContent" template. If you have structured documents with secitons, then you want to ????
 +
 +The XML for the links looks something like the following:
 +
 +<code>
 +Search for Authors: <gsf:foreach-metadata name='dc.Creator'> 
 +   <a><xsl:attribute name="href"><xsl:value-of select="$_httpquery_"/>/TextQuery?qs=1&amp;rt=rd&amp;s1.level=Doc&amp;startPage=1&amp;s1.query=<gsf:meta-value/>&amp;s1.index=CR</xsl:attribute><gsf:meta-value/></a><xsl:text>, </xsl:text>
 +</gsf:foreach-metadata>
 +</code>
 +
 +<gsf:foreach-metadata> iterates over the list of values for the specified metadata, and <gsf:meta-value> outputs the current value each time.
 +
 +The parameters are:
 +  * qs=1  - this search is a quick search. Can omit if you want to be taken to the TextQuery search page (equivalent to clicking the TextQuery link under the quick search form)
 +  * rt=rd  - this determines, for a query, if you are displaying the search form, and performing the search or not. If you have qs=1, then you really only need rt=r here. But without qs=1, having the r will perform the search, and having the d will display the search form too.
 +  * startPage=1  - start at the first page of search results
 +  * s1.level=Doc  - s1 params go to the query service itself. level is Doc or Sec.
 +  * s1.query   - the query term, in this case the metadata value
 +  * s1.index=CR   - the index to search in, in this case the CR dc.Creator index.
 +
  
  
en/user/gs3_sample_format_statements.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1