collectionmacro Style:cssheader '
'
An example collection demonstrating how the appearance of a collection can be modified just by changing the CSS is online at
http://puka.cs.waikato.ac.nz/cgi-bin/library?a=p&c=style-e&p=about ; you can copy the stylesheets used in that collection - [[http://puka.cs.waikato.ac.nz/gsdl/collect/style-e/styles/style-blue.css|blue]] and
[[http://puka.cs.waikato.ac.nz/gsdl/collect/style-e/styles/style-red.css|red]].
=====What are the formatting options available for my collection?=====
Section 2.3 of the [[Manual | Greenstone Developer's Guide]] discusses how to format the output of your collection. However, the list of options is incomplete. The full list of formatting options is shown [[How to format the output of your collection |here]]. But for more information about how to use these options, the developer's guide is the place to go.
=====How can I hyperlink individual metadata elements?=====
//[contributed by Axel Schild]//
When a metadata element has only one value, it is easy to make a hyperlink out of the value. In the format statement, you just put an tag around the metadata item, for example:
:
{If}{[dc.Creator],
This statement includes a label definition with the name "AuthorField". "_httpquery_" is a macro which resolves into the http-address of the query page of the collection. "[cgisafe:sibling(All:\' ; \'):dc.Creator]" displays all Creators, separated by ; and with any special characters escaped for use within a web address. [sibling(All:\'_\'):dc.Creator] produces a similar string without escaping the special characters. Notice the different separation symbols, these are needed later on.
Additional changes have to be made in order to make this whole thing work. You further need to change the _header_ or _textheader_ macro in the package of the page the format string will be displayed in (in this case the document package). The change is that _htmlhead_ has to be parametrized with _htmlhead_(onload="ExtractAuthors();"), where ExtractAuthors(); is a Javascript function that is called on loading the corresponding page (the document display page). Since you do not want to mess in the standard macro files, create an extra.dm file (in gsdl/collect/
}
Authors:
package document
###document display
###HTML-Page Header
_textheader_ [c=exacol] {_cgihead_
_htmlhead_(onload="ExtractSubjects();ExtractAuthors();")
Now all that is missing is the Javascript function which has to be included into the _pagescriptextra_ macro of the same package. Copy this macro out of the corresponding standard macro file and paste it into your extra.dm file. Make the necessary modification which is in this case
_icontab__javalinks_
### Self-made Javascript functions
_pagescriptextra_{
function ExtractAuthors() \{
var res;
a = AuthorField.outerText.split(";");
resolver = a[0]+"&q=";
b = a[1].split("+%3b+");
c = a[2].split("_");
res = "";
for (i = 0; i < b.length ;i++)
\{
res = res + "" + c[i] + "
This Javascript function evaluates the string of the defined label, splits it into several strings and composes a string out of those values, which is then set to the "outerHTML" element of the label. "&h=dd0" indicates which index to search in; dd0 should be replaced with the name of the appropriate index. The file gsdl/collect/
";
\}
AuthorField.outerHTML = res;
\}
}
{If}{[dc.Creator],
Extra.dm:
}
Authors:
package document
# header overridden for text pages
_textheader_ {_cgihead_
_htmlhead_(onload="ExtractAuthors();")
_startspacer_
" + c[i] + " ";
\}
author.innerHTML = res;
\}
}
=====How can I hide the dummy text "This document has no text"?=====
Instead of [Text] in the DocumentText format statement, use
}
### Self-made Javascript functions
_pagescriptextra_{
function ExtractAuthors() \{
var res;
var author = document.getElementById("AuthorField");
a = author.innerHTML.split(":");
resolver = a[0]+"&q=";
b = a[1].split("%3a%5c");
c = a[2].split("_");
res = "";
for (i = 0; i < b.length ;i++)
\{
res = res + "
{If}{[Text] ne 'This document has no text. ',[Text]}
If you have installed Greenstone in a different language, then you need to put the correct language string into the If statement. (Since version 2.62.)
=====How do I suppress the link to the Greenstone text version of a document?=====
Files such as Word and PDF get converted to HTML during processing, and the original file is stored as an associated file. The default display for search results and browsing lists is two icons: a "text" icon, linking to the Greenstone version of the document, and a pdf or word icon, linking to the original file.
In format statements, //[link][icon][/link]// links to the greenstone version and //[srclink][srcicon][/srclink]// links to the original file.
The default VList format statement starts off like
To suppress either of the icons, you can delete the relevant line from the format statement.
If you are suppressing the link to the original, then remove
[link][icon][/link]
[srclink][srcicon][/srclink]
from the format, and you are done.
If you want to suppress the link to the Greenstone version, there are a few complications. Firstly, bookshelf nodes in classifiers must have //[link][icon][/link]// to display the bookshelf. And secondly, you may want to display different icons for different document types.
Here are a few scenarios, and the appropriate format to replace the two lines specified above.
(For PDF documents, you can substitute any that get converted)
*Collection with only PDF documents, linking to the original only, and no bookshelves in classifiers:
[srclink][srcicon][/srclink]
*Collection with only PDF documents, and bookshelves in classifiers:
[srclink][srcicon][/srclink]
*Collection with PDFs for which you want to suppress the text link, and other types where you want to show the text link, and classifiers with bookshelves. The first option will only work if the other document types don't have srcicon metadata.
{If}{[numleafdocs],[link][icon][/link]
,[srclink][srcicon][/srclink]}
=====How do I add cover images for my documents?=====
To add a cover image for a document, you need to create the image and add it to the collection in the same folder as the document. It must be a JPEG file (with file extension .jpg) and have the same name as the document. For example, the cover image for farming.doc must be named farming.jpg. Greenstone automatically looks for jpg files of the same name to assign as cover images. (To disable this, you need to add the -no_cover_image option to the plugins.)
Once you have the cover images, setting the format statement //DocumentImages// to //true// (or enabled in GLI) will result in them being displayed on the document page.
You can also use them as thumbnails in search results and browsing lists, by replacing //[icon]// with something like the following in the appropriate format statement:
{If}{[srcicon],[srclink][srcicon][/srclink], [link][icon][/link]}
{If}{[FileFormat] eq "PDF",[srclink][srcicon][/srclink],[link][icon][/link]}
=====How do I link to other sections of my document?=====
The //_httpdocument_// macro is used to provide a link to a document. For example, if xxx is a document identifier, then the following would link to it:
...
//[DocOID]// gives the OID of the current section, while //[DocTopOID]// gives the top level OID of the document. For documents without internal sections, these two format elements return the same Identifier. (Note, [DocTopOID] available from version 2.72)
So, //_httpdocument&d=[DocOID]// links to the current section of the document, and //_httpdocument_&d=[DocTopOID]// links to the top section of the document.
Document identifiers can be used in conjunction with some modifiers to get different parts of the document. Modifiers include:
* **.pr** parent
* **.rt** root (top level) (from 2.72)
* **.ns** next sibling
* **.ps** previous sibling
* **.fc** first child
* **.pc** previous child
Here are some examples:
^Identifier^Description^
|[DocTopOID] or [DocOID].rt| The top level section of the document|
|[DocOID].ns | The next section of the document (used for next arrow)|
|[DocOID].ps | The previous section of the document (used for prev arrow)|
|[DocTopOID].fc or [DocTopOID].1 | The first subsection of the document|
|[DocTopOID].1.2 | The second subsection of the first section of the document|
=====How do I link to the next or previous search result in a document page?=====
**Since Greenstone 2.72**
**Important Note**: Important Note: This option was inoperative in version 2.72 due to a bug in this release. It has been fixed for subsequent releases.
**Enable the links**
* In GLI -> Format Panel -> Format Features -> Choose Feature
* select //DocumentSearchResultLinks//
* click the //Add Format// button
* tick the Enabled checkbox
Or
* In your collection's //collect.cfg// (in GSDLHOME/collect/your_collection/etc)
* add
format DocumentSearchResultLinks true
**Format the links**
* In document.dm (in GSDLHOME/macros)
* the next and previous search result link are defined in _nextsearchresult_ and _prevsearchresult_ correspondingly, you can put them wherever you want in a document page and customize their apprearance in style.css (in GSDLHOME/images)
* the text for those links are defined in _textnextsearchresult_ and _textprevsearchresult_ in english.dm. Add your corresponding language entries in your_language.dm for languages other than English
=====How do I add a Facebook Like button to a document page?=====
* In document.dm (in GSDLHOME/macros)
Add the following to the _content_ macro
=====How do I display file size in kB or MB?=====
You can do this using Javascript.
Add the following into the _globalscripts_ macro in style.dm. Make sure that it is put inside the existing tags in that macro.
function format_filesize(bytes) \{
var filesize = bytes + " bytes";
if (bytes > 1048576) \{
filesize = Math.round(bytes / 1048576.0) + " MB";
\} else if (bytes > 1024) \{
filesize = Math.round(bytes/1024.0)+ " kB";
\}
document.write(filesize);
\}
Then in your format statement, instead of [FileSize] use