In my last blog I introduced some of the new extensibility features that are now available in the latest Alfresco Community source code and will later appear in Alfresco Enterprise 4.0. I demonstrated how to create and deploy an extension module that added some extra content to a user dashboard page in Alfresco Share. In this blog I'm going to demonstrate how to use an extension module to hide some extra content in an Alfresco Share page.
Our previous module added content to the title bar on the user dashboard, let's take the opposite tack and write a module to completely hide it. If we were targeting a different Component we'd use SurfBug to identify the title bar region-id, source-id and scope properties (see the previous post for a refresher on how to do this) but as we're modifying the same Component we can just copy the configuration from the 'blog-demo.xml' file that you previously created.
Add another <module> entry into the <modules> element - as follows:
<module>
<id>Blog Module (Hide Title)</id>
<components>
<component>
<region-id>title</region-id>
<source-id>user/{userid}/dashboard</source-id>
<scope>page</scope>
<sub-components>
<sub-component id='default'>
<evaluations>
<evaluation id='guaranteedToHide'>
<render>false</render>
</evaluation>
</evaluations>
</sub-component>
</sub-components>
</component>
</components>
</module>
Then follow these steps (they should be familiar from the previous tutorial):
It probably seems like that's a lot of XML to achieve a fairly simple task, but we're really only just scratching the surface of what is possible. Let's explore some of the elements of this configuration more closely...
Every Alfresco Share user gets their own dashboard page (which enables them to customize the layout to suit their own needs) but each user dashboard is generated from a single preset. In the previous blog we targeted only the Admin user dashboard by extending the title region on the 'user/admin/dashboard' template, but here we're targeting all user dashboards by specifying the source template 'user/{userid}/dashboard'.
When the dashboard pages were first created the concept of Sub-Components in Spring Surf did not exist and consequently if you search through the existing dashboard configuration files you won't find any mention of Sub-Components. Spring Surf automatically converts these 'legacy' Components into the new extensible Components containing a single Sub-Component with the ID 'default'.
This allows us to add new content to these legacy Components (as we did in the last blog) or customize the original content without effecting any new content. In this instance by specifying a Sub-Component with an ID of 'default' we are not adding new content but changing the behaviour of the original content. Multiple modules can extend the same Component which is why the deployment order of modules can be important.
I'll be exploring Sub-Components in greater detail in a later blog.
Every Sub-Component can optionally have zero or more evaluations. Each evaluation acts like an AND-gate to a series of evaluators where an evaluation is considered successful if no evaluators fail. If an evaluation contains no evaluators then it is still considered to have evaluated successfully because nothing has failed.
The purpose of an evaluation is to change the behaviour of a Sub-Component in one of three ways:
In this example we're simply overriding the default behaviour of the Sub-Component to prevent it from rendering by setting the <render> element to have a value of false (this defaults to true) if not defined.
I'll be exploring evaluations and evaluators in greater detail in a later blogs, but the purpose of this tutorial is to provide an introduction into customizing existing content.
It would have been possible to add the <sub-component> elements (and its children) into the module created in the previous blog as single module can update multiple Components and Sub-Component. Adding the 'hide' configuration as a separate module allows us to deploy and undeploy both independently. If you deploy both modules you'll see that it's the new content is still rendered despite the the title bar being hidden. It is not necessary to restart the web server between module deployment changes - providing you remember to click the 'Apply Changes' button the updates will be shown the next time you refresh the Alfresco Share page.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.