Thursday, December 17, 2009

Create a Custom Page in Share

In this bog entry, I will add new custom page in Alfresco Share. This page can be added to our site same as other pages like wiki, document library, calendar etc.

I have taken reference from this post.  http://edlovesjava.blogspot.com/search/label/extending%20share

Whenever you want to do any customization in alfresco, rather then doing it from scratch, refer what is out-of-box available and try to follow the same flow.

To add page in alfresco is similar to Alfresco Surf (if you are familiar with that)

Step -1
The starting point of adding Page is , Create a xml file named helloPage.xml in the following folder

C:\Alfresco3.1.2\tomcat\webapps\share\WEB-INF\classes\alfresco\site-data\pages

Add the following code in the file  helloPage.xml
This file defines, title, description and name of template-instance


<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>Hello Page</title>
<description>Simple test page</description>
<template-instance>helloPage</template-instance>
<authentication>user</authentication>
</page>

Step-2
Now, create template-instance named - helloPage.xml in the following folder

C:\Alfresco3.1.2\tomcat\webapps\share\WEB-INF\classes\alfresco\site-data\template-instances

Add the following code in the template-instance file. This file defines the name and path of template file.  Here, file name is – sample-helloPage.ftl and path is org/alfresco/

<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>org/alfresco/sample-helloPage</template-type>
    <properties>
        <hasTreeview>true</hasTreeview>
    </properties>
</template-instance>

Step-3

Now, create template-instance named - sample-helloPage.ftl in the following folder

C:\Alfresco3.1.2\tomcat\webapps\share\WEB-INF\classes\alfresco\templates\org\alfresco

This page actually renders all the required contents of your page.
It may include different components.

Add any template code.
I am adding here simple, text

Add the template as per your requirement




Step-4

Final step is, let Share know about newly added page.

Create or Edit the file named - web-framework-config-custom.xml in the following folder
C:\Alfresco3.1.2\tomcat\shared\classes\alfresco\web-extension

Add the following code in the file web-framework-config-custom.xml

<alfresco-config>

   <config evaluator="string-compare" condition="SitePages" replace="true">
   <pages>
      <page id="helloPage">helloPage</page>
    </pages>
</config>
   
</alfresco-config>


To test the page

Restart the Tomcat(your application server)

Login in to your Share (http://localhost:8080/share/)

Go to the created site,
Click on Customize Site, --> Add Pages
Here you should find our newly created page named  Hello Page.  Add that Page.

In the Top navigation, you should find the new page.

1 comment:

  1. I think that I would prefer that these administrative tasks be broken out into their own menu, but this layout is still workable given the current set of features in Share.

    alfresco workflow

    ReplyDelete