In my earlier blogs describing the new extensibility features my samples have not been particularly practical. Earlier this week I was asked how to extend the Document Library for a site to automatically display the content of any 'readme' files in the current folder. This blog will take you through how I implemented it. This post is not intended to explain the extensibility features but simply to show how they can be applied to achieve a more practical result. These features are currently available in the latest Alfresco Community source and will be in Alfresco Enterprise 4.0.
The extension that we're going to create will automatically display the contents of the first file called 'readme.txt' found in the currently selected folder in a site Document Library.
The standard Document Library (that you'll find on a regular site) is made up of the following Components: filter, tree, tags, toolbar and document list. If you want to change the behaviour of these widgets then you'll to take the following approach:
Override the WebScript that backs the Component and ensure that the *.head.ftl loads your library and that the .html.ftl instantiates your widget.
This approach is not ideal because it requires that you override (rather than extend) a WebScript - however, we are looking at solutions to make this easier. Also, it's important to note that there are other options for specifically extending the Document Library that haven't been blogged about..... yet!
Fortunately this task is possible with the extensibility functions at our disposal because it only requires that we insert something between the toolbar and document list widgets. Using SurfBug we can identify that the Document List is rendered by the Component 'template.documentlist.documentlibrary' and it's Sub-Component 'default' (which was generated from legacy configuration).
The full list of files we'll need are as follows:
A configuration file defining a module that adds a new Sub-Component ('doclib-extension.xml')
A descriptor file for a new WebScript that will display 'readme.txt' content ('auto-readme.get.desc.xml')
A new CSS file with the styling for our Sub-Component ('auto-readme.css')
The files will need to go in the following locations in a JAR file:
Once you've created your JAR, copied it to 'webappsshareWEB-INFlib', restarted Alfresco Share and deployed the module you should be able to see results like those shown below:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.