In this tutorial you will see how to add a new page to Share. In the following tutorial you will see how to make this new page the default landing page. Source code for sample Surf page can be found here .
Adding a new page requires a minimum of three files:
- A Page definition file
- A Template-Instance definition file
- A FreeMarker template file
- This tutorial assumes you have generated an All-In-One SDK 3.0 Project.
- Create a new folder called pages in aio/aio-share-jar/src/main/resources/alfresco/web-extension/site-data.
In the pages folder create a new file called home-page.xml
with the following contents:
<page> <template-instance>home-page</template-instance> <authentication>user</authentication> </page>
This is the page definition file. This defines the page name (which is the file name) and a mapping to a Template-Instance that contains the content. It also defines the level of authentication required to view the page.
- In the aio/aio-share-jar/src/main/resources/alfresco/web-extension/site-data folder, create a subfolder called template-instances.
In the newly created template-instances folder, create a new
file, also called home-page.xml with the following contents:
<template-instance> <template-type>tutorials/home-page</template-type> </template-instance>
This is the Template-Instance definition. This creates a mapping to the actual FreeMarker template that contains the content for the page.
Create a new file in
called home-page.ftl with the following contents:
<html> <head> <title>Tutorials Application</title> </head> <body> Welcome To Extreme Share Customization! </body> </html>
This is the FreeMarker template file. This contains the actual page content. The example shown here is trivial but this could also contain regions for binding Surf components if required.
The implementation of this sample is now done, build and start the application
server as follows:
/all-in-one$ mvn clean install alfresco:run
In your web browser open the following location
You will be prompted with the standard Share login screen.
You are asked to log in because in the page definition file you set the authentication level to be user, that is the page is accessible to all logged in users. To create a page that can only be accessed by administrators using an authentication level of admin. To create a page that can be accessed by any user, including those who are not logged in, set the authentication level to none.
Log in using your credentials.
After logging in your new home page will be displayed.