Here we are creating custom sample page to display in alfresco share.
Instead of mess with original alfresco directory structure or modifying it, we will create that in extension environment.
Here are the steps we go through one by one.
<!-- Add a custom page type -->
================================================
Once you configure all above steps, restart alfresco server.
Open your site, Click More (Top right) -> select Customize site
You will get like below :
Instead of mess with original alfresco directory structure or modifying it, we will create that in extension environment.
Here are the steps we go through one by one.
Adding the Surf Page
Pages are found in our \tomcat\shared\classes\alfresco\web-extension\site-data\pages. We are going to create a file called home.xml which defines our "home" Surf page. The contents of the file look like this:
home.xml
<?xml version='1.0' encoding='UTF-8'?> <page> <id>home</id> <page-type>home</page-type> <title>Home</title> <title-id>page.home.title</title-id> <description>Home Demo page</description> <description-id>page.home.description</description-id> <template-instance>home</template-instance> <authentication>user</authentication> </page>
================================================
The XML is pretty self explanatory here. There is a page element which includes a few elements describing the Surf page. The title element is what is displayed in the web browser and is used in the navigation in Share. The title-id element replaces the title element and is loaded from the properties file. Thedescription and description-id are analogous to the title and title-id. The template-instance element contains the name of the template instance XML definition file, which is discussed next. And finally theauthentication element defines what authentication is required to access the page. Valid values are none, user, and admin.
The XML is pretty self explanatory here. There is a page element which includes a few elements describing the Surf page. The title element is what is displayed in the web browser and is used in the navigation in Share. The title-id element replaces the title element and is loaded from the properties file. Thedescription and description-id are analogous to the title and title-id. The template-instance element contains the name of the template instance XML definition file, which is discussed next. And finally theauthentication element defines what authentication is required to access the page. Valid values are none, user, and admin.
Adding the Surf Template Instance
Template instances are found in our sample project in \tomcat\shared\classes\alfresco\web-extension\site-data\template-instances. We are going to create a file called home.xml which defines our "home" Surf template instance. The template instance effectively ties the Surf page to the Surf template. The contents of the file look like this:
home.xml
<?xml version='1.0' encoding='UTF-8'?> <template-instance> <template-type>org/alfresco/home</template-type> <description>Home</description> <properties> <pageFamily>home</pageFamily> <container>home</container> </properties> </template-instance>==============================================Again, the XML is pretty self explanatory. Inside the template-instanceelement is a series of elements describing the Surf template instance. Thetemplate-type element points to the location of our Freemarker home.ftl file which we will discuss in more detail shortly. The properties element contains apageFamily element and container element, both of which are used by Share for navigation related functions (i.e. highlighting the current page in the navigation component).
Adding the Surf Template
Templates are found in our sample project in \tomcat\shared\classes\alfresco\web-extension\templates\org\alfresco. We are going to create a file called home.ftl which defines our "home" Surf template using Freemarker. You could user plain HTML in your home.ftl template and ignore Freemarker altogether which is essentially what we do in this example. The contents of the file look like this:
<head></head> <body><h1>This is just a demo page. Hello World!</h1></body>This is a very simple example with a "hello world" HTML snippet to demonstrate adding a page to Alfresco Share rather than the complexities of Surf and creating and adding Surf components.
Adding the Properties File
Properties files are found in our sample project in \tomcat\shared\classes\alfresco\messages. We are going to create a file called demo.properties. The contents of the file look like this:
## Custom Messages for Demo Share Sitepage.home.title=Demo Homepage.home.description=Demo Home Description
In order for the new properties file to be loaded by Spring we need to add it to a new file located in \tomcat\shared\classes\alfresco\web-extension called custom-slingshot-application-context.xml. The contents of the file look like this:
(Alfresco share having sample file commented, uncomment it and add below block)
custom-slingshot-application-context.xml
<bean id="webscripts.test.resources" class="org.alfresco.i18n.ResourceBundleBootstrapComponent"> <property name="resourceBundles"> <list><value>alfresco.messages.demo</value></list> </property> </bean>
==========================================
Adding the Page to Current Site Pages
We will need to edit a file called share-config-custom.xml file, located in \tomcat\shared\classes\alfresco\web-extension. The contents of the file look like this:
(Alfresco share having this file commented with .sample, uncomment it and edit it)
<!-- Add a custom page type -->
<config evaluator="string-compare" condition="SitePages" replace="true"> <pages> <page id="home">home</page> <page id="calendar">calendar</page> <page id="wiki-page">wiki-page?title=Main_Page</page> <page id="documentlibrary">documentlibrary</page> <page id="discussions-topiclist">discussions-topiclist</page> <page id="blog-postlist">blog-postlist</page> <page id="links">links</page> <page id="data-lists">data-lists</page> </pages> </config>
================================================
Once you configure all above steps, restart alfresco server.
Open your site, Click More (Top right) -> select Customize site
You will get like below :
No comments:
Post a Comment