Foundry Documentation
User Manual
About Foundry
Layout templates
CSS files
Developer Manual
The structure of Foundry
Coding style
This document describes the coding conventions for the Foundry theming engine.
Naming
The naming rules described here apply to all names: Names of layout elements,
XSL template names, EXSLT functions, files, ids and classes (in the
class attribute).
Use the dash "-" to separate parts of a name instead of camel case or the
underscore. For example: get-setting instead of getSetting or
set_setting.
Names should be lowercase.
Namespace declarations
In the XSL files, XML namespaces are only defined at the
<xsl:stylesheet> element. The XSL namespace is the first one is
declared first. The other namespace follow in alphabetic order (ordered by their
prefix).
Indention, line length and formating
Indention is done using spaces. Indention depth is four (4) spaces per level.
Try to keep the line length below 100 characters per line. Because of some restrictions of XML this will be possible in every case.
Insert a line break after each attribute of an XML element. The first attribute is on the same line as the element. For example write
<xsl:param name=example-param"
select="'example'"/>
instead of
<xsl:param name=example-param" select="'example'"/>
The documentation system of Foundry
XSL Templates and Function references
The version of Foundry. Kept in sync with the version of CCM, so the first version was be 2.2.3. The path the to theme file. This path is used at several points to load files which are part of the theme, like CSS files, images and fonts. The context prefix in which CCM is installed. If CCM is installed into the ROOT context of the servlet container, this variable will be empty. The path on which the CCM dispatcher Servlet is mounted. Usually this is CCM This variables stores the XML created by CCM for later access. This variables stores the XML definition of the Foundry documentation. Activate double click protection on buttons? Activate double click protection on links? The language to use as negotiated by CCM. The languages supported by this theme. They are configured in conf/global.xml using the <supported-languages> element. Example for german and english: <?xml version="1.0"?> <foundry:configuration> … <supported-languages default="de"> <language locale=de"> <language locale=en"> </supported-languages> … </foundry:configuration> The language to use by theming engine for static texts etc. The language is determined as follows: If the negotiated language is also in the supported-languages If not the language which set by the default attribute of the <supported-languages> is used, but only if this language is in the supported languages. Otherwise the first of the supported languages is used. The name of the user agent (browser) which is used to access CCM. Helper functions for generating the name of the colorset class. Helper functions for retrieving the name of the content type of the current content item from the result tree XML. Helper template for processing arrows/links for sorting items. Helper template for processing additional attributes in the data tree XML. They copied literally from the XML the HTML. The name of the template file to process. This template is the entry point for the template parser. Helper template for setting the id and class attributes on a HTML element. A helper template for generating the <link rel="stylesheet" href="..."/> elements for loading the CSS files. The name of the CSS file to load The media for which the file should be loaded. If no set, the CSS file is used for all media types.Function foundry:boolean
A helper function for evaluating certain string values to boolean. This function has two purposes. First it simplifies some expressions. for example if you have a template tag with a attribute containing a (pseudo) boolean value (attribute values are always treated as strings) you would have to write something like:
...
<xsl:if test="./@attr = 'true'">
...
</xsl:if>
...
Using foundry:boolean this can be simplified to
...
<xsl:if test="foundry:boolean(./@attr)">
...
</xsl:if>
...
The more important purpose is to make the usage of boolean values more user
friendly, especially in the templates. Using foundry:boolean no only
true is evaluated to boolean true. A number of other
strings is also evaluated to true:
-
true -
TRUE -
yes -
YES -
t -
T -
y -
Y
All other values are evaluated to false.
Parameters
| Name | Mandatory | Type | Description | value | yes | string |
The value to evaluate. |
|---|
Result
Result type
boolean
Description
The evaluated boolean value.
Function foundry:message
A helper function used by the other message functions like
foundry:message-warn. Concatenates the message level with the message.
This function should not be used directly. Use the other message functions instead.
Parameters
| Name | Mandatory | Type | Description | level | yes | string | message | yes | string |
|---|
Result
Result type
xs:string
Description
A message string of the form [Foundry $level] $message with
$level and $message replaced by the values of the
parameters.
Function foundry:message-info
Helper function to generate an info message. This function be used together with
<xsl:message> to output a message in the CCM log. Example:
...
<xsl:message>
<xsl:message select="foundry:message-info('Hello from Foundry')" />
</xsl:message>
Parameters
| Name | Mandatory | Type | Description | message | yes | string |
|---|
Result
Result type
xs:string
Description
A message string of the form [Foundry INFO] $message with
$message replaced by the value of the parameter.
Function foundry:message-warn
Helper function to generate an info message. This function be used together with
<xsl:message> to output a message in the CCM log warning
the administrator about some things in the theme, for example a missing
configuration file. Example:
...
<xsl:message>
<xsl:message select="foundry:message-info('Something is strange...')" />
</xsl:message>
Parameters
| Name | Mandatory | Type | Description | message | yes | any |
|---|
Result
Result type
xs:string
Description
A message string of the form [Foundry WARNING] $message with
$message replaced by the value of the parameter.
Function foundry:message-error
Helper function to generate an info message. This function be used together with
<xsl:message> to output a message in the CCM log when
something goes wrong in the theme, for example when a layout file has a wrong
structure. Example:
...
<xsl:message>
<xsl:message select="foundry:message-info('Some error has occurred...')" />
</xsl:message>
...
Parameters
| Name | Mandatory | Type | Description | message | yes | any |
|---|
Result
Result type
xs:string
Description
A message string of the form [Foundry ERROR] $message with
$message replaced by the value of the parameter.
Function foundry:get-attribute-value
A helper function for retrieving an attribute value from an element. If the
attribute is set on the current element the value of the attribute is used as
result. If the attribute is not set the default-value is used. This
method is used by several layout tags with optional attributes. A common use pattern
looks like this:
<xsl:template match="example">
<xsl:variable name="width"
select="foundry:get-attribute-value(current(), 'width', '640')" />
<xsl:variable name="height"
select="foundry:get-attribute-value(current(), 'height', '480')" />
/<xsl:template>
In this example, the element example has two optional attributes:
with and height. If the attribute is set in processed XML,
the value set there is used. Otherwise the default value (640
respectively 480) is used. Without this function a code block like the
one in the xsl:choose block of this function would be necessary for
each of the variables.
Parameters
| Name | Mandatory | Type | Description | node | any | attribute-name | any | default-value | any |
|---|
Result
Result type
any
Description
The value of the attribute if it is set on the current element, the
default-value otherwise.
Function foundry:get-setting
Convenient function for calling foundry:get-setting with only the
module name and setting name.
Parameters
| Name | Mandatory | Type | Description | module | yes | string |
The module of the settings. May be an empty string ( |
setting | yes | string |
The name of the setting to retrieve. |
|---|
Result
Result type
string
Description
The value of the setting.
Function foundry:get-setting
Convenient function for calling foundry:get-setting with only the
module name, the setting name and an default value.
Parameters
| Name | Mandatory | Type | Description | module | yes | string |
The module of the settings. May be an empty string ( |
setting | yes | string |
The name of the setting to retrieve. |
default | yes | string |
A default value which is used when the setting is not configured. |
|---|
Result
Result type
string
Description
The value of the setting or the default value if the setting is not configured.
Function foundry:get-static-text
Retrieves at static text. For more informations about static texts in Foundry please refer to the static texts section in the Foundry documentation.
Parameters
| Name | Mandatory | Type | Description | module | yes | string |
he module of the settings. At the moment this corresponds to the name of the file
in the |
id | yes | string | lang | no | string |
The language to retrieve. Normally there is no need to set this parameter because it is determined automatically. |
|---|
Result
Result type
string
Description
The requested static text. If there is no value for the requested static text in the
module provided by the module parameter the value depends if the debug mode is
enabled or not. If the debug mode is not not enabled the result is an empty
string. If the debug mode is enabled, a identifier of the text (the value of the
id parameter) is displayed. If you point the mouse pointer of the
placeholder, the complete path of the text is shown as hovering box.
Function foundry:debug-enabled
A helper function to determine if the debug mode should be enabled. The debug mode of foundry is automatically enabled if the theme is viewed as development theme.
Result
Result type
any
Description
true if the debug mode if active, false otherwise.
Function foundry:read-current-category
Result
Result type
any
Description
The path of the current category.