_content_ {Oops
_textdefaultcontent_}
The page will read “Oops” at the top, and //_textdefaultcontent_//, which is defined, in English, to be //The requested page could not be found. Please use your browsers 'back' button or the above home button to return to the Greenstone Digital Library,// and in other languages to be a suitable translation of this sentence.
//_textdefaultcontent_// and //_content_// both reside in the //global// package because they are required by all parts of the user interface. Macros can use macros from other packages as content, but they must prefix their names with their package name. For example,
_collectionextra_ {This collection contains _about:numdocs_ documents. It was last built _about:builddate_ days ago.)
comes from //english.dm//, and is used as the default description of a collection. It is part of the //global// package, but //_numdocs_// and //_builddate_// are both in the //about// package—hence the //about:// preceding their names.
Macros often contain conditional statements. They resemble the format string conditional described above, though their appearance is slightly different. The basic format is //_If_(x,y,z)//, where //x// is a condition, //y// is the macro content to use if that condition is true, and //z// the content if it is false. Comparison operators are the same as the simple ones used in Perl (less than, greater than, equals, not equals). This example from //base.dm// is used to determine how to display the top of a collection's //about// page:
_imagecollection_ {
_If_( "_iconcollection_ " ne "",
,
_imagecollectionv_)
}
This looks rather obscure. //_iconcollection_// resolves to the empty string if the collection doesn't have an icon, or the filename of an image. To paraphrase the above code: If there is a collection image, display the //About this Collection// page header (referred to by //_httppageabout_//) and then the image; otherwise use the alternative display //_imagecollectionv_//.
Macros can take arguments. Here is a second definition for the //_imagecollection_// macro which immediately follows the definition given above in the //base.dm// file:
_imagecollection_[v=1]{_imagecollectionv_}
The argument //[v=1]// specifies that the second definition is used when Greenstone is running in text-only mode. The language macros work similarly—apart from //english.dm//, because it is the default, all language macros specify their language as an argument. For example,
_textimagehome_ {Home Page}
appears in the English language macro file, whereas the German version is
_textimagehome_ [l=de] {Hauptaseite}
The English and German versions are in the same package, though they are in separate files (package definitions may span more than one file). Greenstone uses its //l// argument at run time to determine which language to display.
package about
##############################################
# about page content
###############################################
_pagetitle_ {_collectionname_}
_content_ {
_navigationbar_
_query:queryform_
_iconblankbar_
_textabout_
_textsubcollections_
_help:textsimplehelpheading_
_help:simplehelp_
}
_textabout_ {
_textabcol_
_Global:collectionextra_
}
As a final example, Figure
_package:macroname_
eg. _home:textpagetitle_
The package name can be omitted if you are referencing a macro from the same package.
Check a macro from the defined package. If this macro is not existing, a warning message "macro is not defined" is returned.
===== How macros work =====
* Once an action (eg. a=p&p=home) is sent to cgi-bin/library, external macros used for all actions are firstly defined (eg. navigation bar). Then the internal macros of this paticular action is defined. All macros are stored in a kind of hash structure.
* Set macro(macroname,package,content) when the action is executed.
OutputStream<