The metadata template refers to the section of the document “browse” page under the file name. This area can be customized with node properties and/or by custom rendering functions.
In a clean install, there are two templates defined: the default (fallback) template and one used when rendering working copies. These are both defined within share-documentlibrary-config.xml and can be extended or overridden as required (by using share-config-custom.xml).
The metadata templates are located in the <metadata-templates> config container element with the following structure:
<templateid> <evaluator /> <line id (index) (simpleView) (evaluator) /> <override /> </template>
where:
-
<template>: Template element with the following attribute:
- id: Unique template id
- <evaluator>: Bean id of evaluator that determines whether the template is to be used for this node or not. The Evaluator extends org.alfresco.web.evaluator.BaseEvaluator
-
<line>: Allows placeholder values within i18n label to be
replace at runtime with node properties. The value refers either to a node property
(such as cm_description) or a customer JavaScript renderer. To add
a label in front of the property, add the label’s i18n messageId after the property
value, separated by a space (such as {cm_description
details.description}. The attributes are:
- id: Id of the line within the template. Must be unique within this template.
- index: Optional index for ordering the lines when rendering.
- view: If set to “simple” or “detailed”, then this line will only be rendered when either the simple or detailed view is toggled on, respectively. Leave empty, or omit the attribute for both views.
- evaluator: Optional evaluator to determine whether this line will be rendered for a node when using the template.
Example config
<configevaluator="string-compare"condition="DocumentLibrary"> ... <template id="isPhoto"> <evaluator>evaluator.doclib.metadata.hasExif</evaluator> <line index="10" id="date" view="detailed">{date}{size}</line> <line index="20" id="exposure" evaluator="evaluator.doclib.metadata.hasExposure"> {exposure exif.label.exposure} </line> <line index="30" id="description" view="detailed">{description}</line> <line index="40" id="social" view="detailed">{social}</line> </template> </config>
Custom JavaScript renderers
A renderer can either be a simple property value, or use a custom JavaScript renderer. To register a custom renderer, fire a Bubbling (global) event, passing-in the renderer id and the rendering function:
if (Alfresco.DocumentList) { YAHOO.Bubbling.fire("registerRenderer", { propertyName: "renderer id", renderer: function(record, label) { return "..."; } }); }
The rendering function should return property escaped HTML.