Create pages in Alfresco Share using new 'out of the box' templates

Showing results for 
Search instead for 
Did you mean: 

Create pages in Alfresco Share using new 'out of the box' templates

Active Member
0 3 7,991


This blog post explains how you can speed up the development of creating pages in Alfresco Share by using a couple of  'out of the box templates'.

The idea is that when creating a 'simple' page in Share with 1, 2 or 3 column you shouldn't have create your own template-instance.xml and template.ftl file. Instead you can re-use one of the 6 out of the box templates described below. That means that you only need to define 1 page.xml-definition in which you tell which webscripts to display inside each region.

The out of the box templates described below are using 'page scoped' regions which means that they can be configured from within a page.xml file. They also make use of a new Spring Surf feature that makes it possible to associate multiple webscripts to a single template region, a feature that was made available in Alfresco Community 4.0.a release.

Note! The actual out of the box templates were made available on HEAD in revision 31068. - They are thereby NOT included in the 4.0a release, so to use them you need to either download the Alfresco Community 4.0.b release OR (to use them in Alfresco Community 4.0.a) do the following...

  1. Download the patch (which contains the 6 out of the box templates)

  2. Rename it from .zip to .jar

  3. Place it in your <SHARE_TOMCAT_HOME>/shared/classes directory

  4. Restart your server

Now we will take a look at how the new templates look and then give an example of how to use them.


The templates

Below you can see the 6 templates in action. I have created sample pages using them to make it easy for you to understand the structure of each template.

I am using the components/title/simple-title.get webscript to display the blue title (i.e. 'TEST 1 COLUMN') and a custom webscript created for this blog post (components/test/echo.get available in the source code for this blog post) to display the 'Echo strings' (i.e. 'Echo: FIRST').

To test out them out yourself just:

  1. Download the sample source code (which contains the test pages & the Echo webscript).

  2. Rename it from .zip to .jar.

  3. Place it in your <SHARE_TOMCAT_HOME>/shared/classes directory.

  4. Restart your server.

  5. Follow the links below to view each template.


1-column (regions: title & column)



2-columns (regions: title, left-column & right-column)



2-columns-narrow-left (regions: title, left-column & right-column)



2-columns-narrow-right (regions: title, left-column & right-column)



2-columns-resizable (regions: title, left-column & right-column)



3-columns (regions: title, left-column, middle-column & right-column)



How to create a page that uses one of the templates

We will create a page named 'test-1-column' that will use the 1-column template and will be reachable at http://localhost:8081/share/page/my-1-column-test.

As you can see below the 1-column template contains 2 'page scoped' regions (title & column) that therefore can be configured from within a  page.

To get the result as above do the following:

  1. Create the following directory stucture <SHARE_TOMCAT_HOME>/shared/classes/config/alfresco/site-data/pages

  2. Create a new page in the directory above and name it to my-1-column-test.xml

  3. In my-1-column-test.xml reference the webscripts you want to include in each region, i.e. using the code below.


<?xml version='1.0' encoding='UTF-8'?>


   <title>Test 1 column</title>

   <description>Test 1 column</description>




      <!-- Title -->





            <title>TEST 1 COLUMN</title>



      <!-- Column -->




            <sub-component id='first'>






            <sub-component id='second'>










First note that we use the <template-instance> element to define that the 1-column template shall be used.

Then note that the syntax used to 'bind in' the webscripts into a region are different in the two regions.

In the 'title' region we only need one webscript and therefor we use the same old syntax that has been used in Share since day 1.

In the 'column' region, however, we want to add in multiple webscripts into the same region. We therefore  have to use the new <sub-components>-syntax to get the job done (available since the Alfresco Share Community 4.0a release). Using this syntax means that you can add in as many webscripts as you like in 1 region. Note! Make sure you make the 'id' attribute in the <sub-component> element 'unique per region'.

To test your page make sure you have installed as described earlier, if so just point your browser to: http://localhost:8081/share/page/my-1-column-test


Further reading

More about the new syntax for 'binding in' webscripts into a region can be found here: