This page is in the 'old' namespace, and was imported from our previous wiki. We recommend checking for more up-to-date information using the search box.

How to format the output of your collection

The full list of formatting options is shown here. But for more information about how to use these options, the developer's guide is the place to go.

Site-wide formatting options

These should be placed in gsdl/etc/main.cfg.

Syntax: SiteFormat <option-name> <option-value>

ItemDescription
HomePageCols intSet the number of columns used to display collections on the home page. Default: 3
HomePageType pulldown Display the collection list on the home page as a pulldown menu, rather than using the default table of collection images. This alters the html that appears in the dynamically generated _homeextra_ macro. You can then move this macro around in home.dm. Default: not set

Collection-specific formatting options

These should be placed in gsdl/collect/<collname>/etc/collect.cfg.

Syntax: format <option-name> <option-value>

ItemDescription
DocumentImages true/falseIf true, display a cover image at the top left of the document page Default: false
DocumentTitles true/falseIf DocumentImages is false, and this is true, use DocumentHeading to display the title. Default: true
DocumentHeading formatstringThis is used for a document heading at the top left if DocumentImages is false and DocumentTitles is true. Default: {Or}{[parent(Top):Title],[Title],untitled}
DocumentContents true/false Display table of contents (if document is hierarchical), or next/previous section arrows and "page k of n" text (if document is paged) Default: true
DocumentButtons stringControls the buttons that are displayed on a document page. Valid options are Detach, Highlight, Expand Text, Expand Contents. Should be separated by |. Default: "Detach|Highlight"
DocumentText formatstringFormat of the text to be displayed on a document page Default: <center> <table width=537> <tr><td>[Text]</td></tr> </table> </center>
DocumentArrowsTop true/falseDisplay next/previous section arrows at top of document, underneath the navigation bar, on document page Default: false
DocumentArrowsBottom true/falseDisplay next/previous section arrows at bottom of document page Default: true
DocumentSearchResultLinks true/falseDisplay next search result link/previous search result link at top of a document page Default: false
DocumentUseHTML true/falseIf true, each document is displayed in a separate frame. The Preferences page will also change slightly, adding options applicable to a collection of HTML documents. Default: false
NavigationBar pulldownIf set, provides a drop down list in place of the usual navigation bar (that contains search and classifier options). This alters the html that appears in the dynamically generated _navigationbar_ macro. Default: not set
AllowExtendedOptions true/falseThis allows the entire content of the document page to be controlled by format statements. Use DocumentHeading and DocumentText to format the document. This option prevents the other hard coded stuff (table of contents, buttons etc) from being output. It effectively disables the DocumentContents, DocumentButtons, DocumentImages format options. New format items are provided for use in format statements if AllowExtendedOptions is true (see table below) Default: false
SearchTypes string Controls whether plain and/or form search interfaces should be available for the collection (for mgpp and lucene collections only). Can be one or both of "plain" and "form". If both are listed, separate with ',', i.e. plain,form. The first one becomes the default search interface style, and the other one is selectable from the preferences page. Default: plain,form
AllowUserComments true/falseControls whether or not the User Comments area is displayed, where existing user comments on a document are displayed and where users can log in to add their comments to documents.

Formatting Lists

The standard use of format statements is for the lists in search results, classifiers etc. Here is a list of the various lists available for format, and what they control. Note that classifiers are numbered from 1 upwards, in the order that they appear in the config file.

ItemDescription
VListApplies to all vertical lists, unless overridden by a more specific format item. These include search results, classifier lists, and document table of contents
HListApplies to all horizontal lists. Horizontal lists are often used in classifiers, particularly AZ[Compact][Section]Lists
DateListApplies to all date lists - these are the vertical lists generated by a DateList classifier.
SearchVListThe vertical list of search results
DocumentVListThe document table of contents
CL1VListApplies only to the vertical list of classifier 1
CL1HListApplies only to the horizontal list of classifier 1
CL1DateListApplies only to the DateList in classifier 1

Formatstring items

ItemDescription
[link][/link]Link to the document (Greenstone version)
[href]The href of the link to the document (Greenstone version), without the &amp;lt;a&amp;gt; tag
[srclink][/srclink]Link to the original document (only if the original was converted to another form)
[equivDocLink][/equivDocLink]Link to an associated document (only if the associated document was formed using the plugin option associate_ext or associate_tail_re). See the documented example collection Associate File for more details.
[icon]An appropriate icon for a classifier/document node. E.g. bookshelf, book, chapter, page
[srcicon]An appropriate icon for the original source document. E.g. Word, PDF, PS icon.
[equivDocIcon]An appropriate icon for a document that has been associated using the plugin option associate_ext or associate_tail_re. See [equivDocLink] above.
[num]The document number (position in the search results - useful for debugging)
[numleafdocs]The number of documents below the current classifier node. This is often used as a test for classifier nodes, as numleafdocs will not be set for documents. This allows different formatting for classifier nodes and document nodes in a hierarchy.
[Text]The text of the current section
[RelatedDocuments]Related Documents info (if available). This is a vertical list of Titles (or Subjects if Titles aren't available) that link to the related documents. It is based on "relation" metadata, which is a space separated list of collection,OID pairs.
[highlight][/highlight]These are used for 'highlighting' (actually bolding) the selected section in a hierarchical table of contents, and the selected node in a classifier. Apart from those two cases, this has no effect. If you actually want to highlight/bold/italicise something in a list, and have it apply to all items in the list, then either use actual html tags, like <b></b>, <u></u> and <i></i>, or use the _starthighlight_ and _endhighlight_ macros (defined in macros/base.dm).
[Summary]Displays Summary metadata if available, otherwise displays a short summary created on the fly.
[DocOID]The internal identifier of the current section of the document
[DocTopOID]The (top level) internal identifier of the current document (available 2.72)
[DocRank]The rank of the current document - used in search results
[DocImage]The URL to the cover image of the document
[collection]The directory name of the collection this document is from - useful in cross-collection searching. (version 2.61)
[collection:meta-name]A collection metadata for the collection this document is from - useful in cross-collection searching. E.g. [collection:collectionname]. This will display in the current language if an appropriate version is available. (version 2.61)
[metadata-name]The value of this metadata element for the document

Extended metadata names

There are a few options for displaying metadata. The basic way is to specify e.g. [Title] or [dc.Title]: this displays the value of that particular metadata element for the current document/section. Metadata names can be prefixed by parent: or sibling. The following examples all use Title or Subject metadata, but any metadata could be used, including ones with namespaces (e.g. dc.Title). Any metadata name can also be prefixed by "cgisafe:". This results in the value being formatted so that it is safe to put in a URL.

ItemDescription
[parent:Title]The Title of the immediate parent section
[parent(Top):Title]The Title of the topmost parent section
[parent(All):Title]All Titles of the parent sections, separated by nothing
[parent(All': '):Title]All Titles of the parent sections, separated by ": " (or whatever appears inside the ' ')
[child:Subject]The Subjects of all child nodes of the current node, separated by ' '. (child modifier avilable from version 2.61)
[child(All'xxx'):Subject]The Subjects of all child nodes of the current node, separated by xxx
[child(2):Subject]The Subject of the second child of the current node. Child numbering starts from 1.
[child(last):Subject]The Subject of the last child of the current node. 'first' is also a valid option.
[sibling:Subject]All Subjects of the current section, separated by " ". This is used for displaying metadata where there is more than one value. [Subject] will just display the first value.
[sibling(All' '):Subject]All Subjects of the current section, separated by .
[sibling(2):Subject]The second Subject metadata value for the current node. Numbering starts from 1.
[sibling(last):Subject]The last Subject metadata value for the current node. 'first' is also a valid option.
[parent:sibling:Subject]sibling can be combined with parent to give all (or specific) values for the parent node(s). All parent and sibling qualifiers can be used. (since version 2.61)
[child:sibling:Subject]sibling can be combined with child to give all (or specific) values for the child node(s). All parent and child qualifiers can be used. (since version 2.61)
[cgisafe:parent(Top):Title]The Title of the topmost parent section, made safe for URLs.
[cgisafe:sibling(All' '):Subject]All Subjects of the current section, separated by , made safe for URLs.
[format:Date]A nicely formatted version of Date metadata. format: can also be used with Language metadata (since version 2.71)

Extended Formatstring items

These items are only available if AllowExtendedOptions is true.

ItemDescription
[DocumentButtonDetach]The Detach button
[DocumentButtonHighlight]The Highlight button
[DocumentButtonExpandText]The Expand Text button
[DocumentButtonExpandContents]The Expand Contents button
[DocTOC]The table of contents for a hierarchical document, or the next/previous and go to page x bits for a paged document.

Conditional expressions in formatstrings

ItemDescription
{If}{[metadata], action-if-non-null, action-if null}If there is a value for this metadata element, then output the first clause, otherwise output the second clause. Either clause is optional: if empty, nothing will be done for that case.This is useful for displaying classifier nodes differently to document nodes: {If}{[numleafdocs],format for classifier,format for document}
{Or}{[metadata], [metadata2], [metadata3]…}Each metadata is evaluated in turn, and the first one that exists is output Useful for cases where there are different namespaced version of the same metadata, e.g. {Or}{[dc.Title],[dls.Title],[Title],Untitled}. The last item can be plain text.
nested If/Or{Or} can have another conditional as its final option, eg {Or}{[BookTitle],[Title],{If}{[XXX],aaa,bbb} }. The following is not valid: {Or}{[BookTitle],[Title]{If}{[XXX],aaa,bbb} }. {If} can have nested conditionals at either true/false option. eg. {If}{[numleafdocs],[Title],[BookTitle]{If}{[Subject],[Subject],unclassified} }
{If}{[metadata] op value, action-if-true, action-if-not-true}Can do tests on metadata values. These can be string comparisons, or numeric comparisons. Valid operators are:
StringNumericMeaning
eq==equals
ne!=not equals
gt>greater than
ge>=greater than or equal to
lt<less than
leless than or equal to
sw starts with
ew ends with

Note that only eq and ne are available for Greenstone versions 2.60 and earlier.

Preserving the original directory structure of your collection for browsing

The situation: You have a nested folder structure which you have dragged and dropped into Greenstone, and you want to have this folder available for browsing in the built collection.

To achieve this:

  • Open the GLI application (Greenstone librarian interface).
  • If you had already created it, open your existing collection–the one with the folder structure–in GLI.

Otherwise create such a collection by dragging and dropping your nested folder structure into the right-hand panel of GLI's Gather tab.

Next you'll be creating metadata that specify a relative directory path, so that the folder structure is mirrored in the browsing classifier:

  • Click on the Design tab. In the left-hand pane, select Browsing Classifiers. Choose to add a Hierarchy classifier from the drop down box in the right-hand pane.
  • Configure the Hierarchy classifier you've just added by clicking on the Configure Classifier button at the bottom:
  • set its "separator" field to: [\\\/|\\\\]
  • in the "metadata" field, choose a metadata field that you think makes sense to specify the folder structure in. For example, you may choose dc.Subject and Keywords. In the example collection I created, I just picked dc.Resource Type.
  • Click on the Enrich tab.

We're going to assign the directory structure as metadata now.

  • In the left-hand panel, browse to each of the innermost subfolders: the folders that contain the actual files. Perform the following for each of these innermost FOLDERS:

Click to select this folder and set the metadata for the field you chose in (4) above to be the relative directory path to this folder.

For instance, assume that the metadata field you wanted to set was dc.Resource Type. If one of the innermost folders you were working with was labelled "1ASCii" and was nested inside the folder structure Encodings/Ascii/, then you'd go down into the 1ASCii folder and type "Encodings/Ascii/1ASCii" as the value for the dc.Resource Type metadata. This is because the folder 1ASCii was nested inside folder Ascii which was located in Encodings.

  • If you've provided the directory path for each of the inner folders in the chosen metadata field, then click on the Create tab and press the Build Collection button.
  • Once built, preview the Collection by pressing the Preview Button.
  • In the web browser that opens, click on the link of the browing classifier for which you added the Hierarchy classifier. For instance, if the dc.Resource Type metadata was associated with the Hierarchy Classifier (as in the example in (6) above), then you'd click on the classifier "types" and browse down to see the files.