Extension Point: Document Library
Description:
When custom content models are deployed to the repository it is sometimes a requirement to display properties from these in the Document Library Browse view. This can be done with so called Metadata Templates, which are tied to an evaluator that decides if the template is applicable or not to the content item in question, such as a folder or a file.
If there is no specific Metadata Template defined for a content item type then it falls back on a default Metadata template that looks like this (all out-of-the-box Metadata Templates can be found in alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/share-documentlibrary-config.xml):
<templateid="default"> <banner index="10" id="lockBanner" evaluator="evaluator.doclib.metadata.hasLockBanner">{lockBanner}</banner> <banner index="20" id="syncTransientError" evaluator="evaluator.doclib.metadata.hasSyncTransientErrorBanner">{syncTransientError}</banner> <banner index="30" id="syncFailed" evaluator="evaluator.doclib.metadata.hasSyncFailedBanner">{syncFailed}</banner> <line index="10" id="date">{date}{size}</line> <line index="20" id="description" view="detailed">{description}</line> <line index="30" id="tags" view="detailed">{tags}</line> <line index="40" id="categories" view="detailed" evaluator="evaluator.doclib.metadata.hasCategories">{categories}</line> <line index="50" id="social" view="detailed">{social}</line> </template>
This template gives you the basic information for the node, such is in the following example for a file:
This tutorial will demonstrate how to add a custom DocLib Metadata Template for a custom type from a content model that comes with the SDK Samples. This content model has a type called acme:document that contains a property called acme:documentId (for more info see aio/aio-platform-jar/src/main/resources/alfresco/module/aio-platform-jar/model/content-model.xml). We will create a new template that displays this custom property. The template will be based on the default template that you can see above and the property will use the default presentation rendering.
The tutorial will also show how you can render a property in a custom way in your Metadata template.
Implementation Steps:
Adding a new Metadata Template to the Document Library involves the following steps:
Related Information:
This tutorial assumes that you are familiar with the Document Library in Share.
Source Code: Go to code
This tutorial assumes you have created a new SDK All-In-One project.
This tutorial will demonstrate the following:
- How to create a custom DocLib Metadata Template for the acme:document type, which is part of the SDK AIO project by default. The template will be based on the default one but will also display the acme:documentId property.
- How to define an evaluator for a custom content type
- How to add another field to the custom template that displays the acme:documentId property in a custom way (i.e. custom rendering)
- Configure the template so it is known to Share (typically in a Surf Extension Module)
- Add an evaluator that controls for what content nodes (i.e. file, folder, etc.) the template is applicable
- Add property labels to the i18n resource file(s)
- (Optionally) Implement custom client side JavaScript code that renders the property in a custom way