en:user:macros
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:user:macros [2014/04/13 23:52] – external edit 127.0.0.1 | en:user:macros [2023/03/13 01:46] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <TABAREA tabs=" | + | |
- | <TAB> | + | |
- | ===== Macros ===== | + | |
+ | ====== Greenstone 2 Macros | ||
Macros define either strings on the interface or variables utilized in C++ codes. By using macros, users can easily customize the user interface without changing any C++ code. | Macros define either strings on the interface or variables utilized in C++ codes. By using macros, users can easily customize the user interface without changing any C++ code. | ||
- | <!-- id:700 -->The entire Greenstone user interface is controlled by macros which reside in the // | + | The entire Greenstone user interface is controlled by macros which reside in the // |
- | <!-- id:701 -->Web pages are generated on the fly for a number of reasons, and the macro system is how Greenstone implements the necessary flexibility. Pages can be presented in many languages, and a different macro file is used to store all the interface text in each language. When Greenstone displays a page the macro interpreter checks a language variable and loads the page in the appropriate language (this does not, unfortunately, | + | Web pages are generated on the fly for a number of reasons, and the macro system is how Greenstone implements the necessary flexibility. Pages can be presented in many languages, and a different macro file is used to store all the interface text in each language. When Greenstone displays a page the macro interpreter checks a language variable and loads the page in the appropriate language (this does not, unfortunately, |
==== The macro file format ==== | ==== The macro file format ==== | ||
- | <!-- id:703 -->Macro files have a //.dm// extension. Each file defines one or more // | + | Macro files have a //.dm// extension. Each file defines one or more // |
- | <!-- id:704 -->Macros have names that begin and end with an underscore, and their content is defined using curly brackets. Content can be plain text, html (including links to Java applets and JavaScript), | + | Macros have names that begin and end with an underscore, and their content is defined using curly brackets. Content can be plain text, html (including links to Java applets and JavaScript), |
< | < | ||
Line 19: | Line 20: | ||
</ | </ | ||
- | <!-- id:705 -->The page will read “Oops” at the top, and // | + | The page will read “Oops” at the top, and // |
- | <!-- id:706 -->// | + | // |
< | < | ||
Line 27: | Line 28: | ||
</ | </ | ||
- | <!-- id:707 -->comes from // | + | comes from // |
- | <!-- id:708 -->Macros often contain conditional statements. They resemble the format string conditional described above, though their appearance is slightly different. The basic format is // | + | Macros often contain conditional statements. They resemble the format string conditional described above, though their appearance is slightly different. The basic format is // |
< | < | ||
Line 41: | Line 42: | ||
</ | </ | ||
- | <!-- id:709 -->This looks rather obscure. // | + | This looks rather obscure. // |
- | <!-- id:710 -->Macros can take arguments. Here is a second definition for the // | + | Macros can take arguments. Here is a second definition for the // |
< | < | ||
Line 49: | Line 50: | ||
</ | </ | ||
- | <!-- id:711 -->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 // | + | 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 // |
< | < | ||
Line 55: | Line 56: | ||
</ | </ | ||
- | <!-- id:712 -->appears in the English language macro file, whereas the German version is | + | appears in the English language macro file, whereas the German version is |
< | < | ||
Line 61: | Line 62: | ||
</ | </ | ||
- | <!-- id:713 -->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. | + | 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. |
< | < | ||
Line 89: | Line 90: | ||
- | <!-- id:715 -->As a final example, Figure <imgref figure_part_of_the_aboutdm_macro_file> | + | As a final example, Figure <imgref figure_part_of_the_aboutdm_macro_file> |
==== Using macros ==== | ==== Using macros ==== | ||
- | <!-- id:717 -->Macros are powerful, and can be a little obscure. However, with a good knowledge of html and a bit of practice, they become a quick and easy way to customise your Greenstone site. | + | Macros are powerful, and can be a little obscure. However, with a good knowledge of html and a bit of practice, they become a quick and easy way to customise your Greenstone site. |
- | <!-- id:718 -->For example, suppose you wanted to create a static page that looked like your current Greenstone site. You could create a new package, called //static//, for example, in a new file, and override the // | + | For example, suppose you wanted to create a static page that looked like your current Greenstone site. You could create a new package, called //static//, for example, in a new file, and override the // |
- | <!-- id:719 -->To change the “look and feel” of Greenstone you can edit the //base// and //style// packages. To change the Greenstone home page, edit the //home// package (this is described in the // | + | To change the “look and feel” of Greenstone you can edit the //base// and //style// packages. To change the Greenstone home page, edit the //home// package (this is described in the // |
- | <!-- id:720 -->Experiment freely with macros. Changes appear instantly, because macros are interpreted as pages are displayed. The macro language is a useful tool that can be used to make your Greenstone site your own. | + | Experiment freely with macros. Changes appear instantly, because macros are interpreted as pages are displayed. The macro language is a useful tool that can be used to make your Greenstone site your own. |
Line 193: | Line 194: | ||
* [[en: | * [[en: | ||
* [[http:// | * [[http:// | ||
- | </ | ||
- | </ | ||
en/user/macros.1397433133.txt.gz · Last modified: 2018/07/31 00:51 (external edit)