Content Files
Content Files contain Macro definitions. Here is a sample Content File:
[@TITLE]:
Welcome to Webgenz
[@]
[@BODY_CONTENT]:
Welcome to Webgenz CMS. The program is
designed to help you build and maintain
web sites more efficiently than ever before.
[@]
Notes:
- The Macro value is contained within start and end tags. The start tag is the Macro tag itself followed by ":". The
end tag is [@]. The end tag must appear on a line by itself.
- Additional Macro references may appear within a Macro definition. In other words, Macros can be nested.
- IMPORTANT To preserve the format of the generated HTML Document, each line of a multi-line Macro value will be
prefaced with whatever text (typically white space) appears to the left of the Macro reference in the Template
File. If there is HTML code to the left of a Macro reference in a Template File, the Macro value should be
a single-line value, unless you intend to prefix each line of the Macro value with this HTML code. Accordingly,
it is usually best to place a Macro reference on its own line in a Template file -- unless you are sure that the Macro value
is only a single-line value. Read more >
Advanced Topics:
- "Inheritance" is a core concept in Webgenz CMS. When Webgenz CMS attempts to replace a Macro reference with a Macro value, Webgenz CMS will
first look to see if the Macro is defined in the primary Content File. If it is not defined in the primary Content File,
Webgenz CMS will search through the Content File hierarchy looking for the definition of the Macro.
- It is possible to "subclass" Macros. For example, a Global Content File might contain a Macro called
[@JAVA_SCRIPT]
which contain a block of Java Script code that should be available to any Document in the Project. A primary Content File
can define its own [@JAVA_SCRIPT] Macro as follows:
[@JAVA_SCRIPT]:
some JavaScript code
[@^JAVA_SCRIPT]
[@]
The last line of this Macro value is a reference to the same Macro, but the "^" indicates that Webgenz CMS
should start looking for the Macro value starting from the next level in the Content File hierarchy.
- Parameters can be passed into Macros. A Macro that takes Parameters is defined as follows:
[@MY_MACRO(@a:1)(@b:2)(@c)]:
This Macro prints the values (@a), (@b), and (@c).
The Parameters "a" and "b" have default values,
the Parameter "c" does not.
[@]
This Macro defines three Parameters: "a", "b", and "c". The Parameters "a" and "b" are defined with the default values "1" and "2".
This Macro can be referenced in a Template File in any of the following ways:
[@MY_MACRO] - When referenced without any Parameters, the default values for the
Parameters are used.
[@MY_MACRO(@a:Yes)(@b:No)(@c:Maybe)] - When referenced with Parameters, the
values passed into the Macro will be substituted for the Parameters in the Macro.
[@MY_MACRO(@c:Maybe)(@b:No)(@a:Yes)] - The order of Parameters is not important. Parameters
are referenced by name, not position.
[@MY_MACRO(@a:Yes)] - Parameters are optional. If a value is not supplied for
a Parameter, the default value will be used. If no default value is provided, the Parameter is replaced with blank space.
|