Add a new page to Alfresco Share with link in Share Header | Code Factory

Code Factory
2 min readDec 13, 2019

--

Reference Link : Link

Following steps are needed to add a Surf Page:

  • Add a Surf Page definition file (XML)
  • Add a Template Instance file (XML)
  • Add a physical Template file (FTL)
  • Add a properties file (.properties) — Optional but good practice
  • Add Web Script(s) that fetches content to display (if you have page scoped regions and use an existing template)

File : helloworldhome.xml ( <Alfresco> -> tomcat -> shared -> classes -> alfresco -> web-extension -> site-data -> pages )

<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>Hello World Home</title>
<title-id>page.helloworldhome.title</title-id>
<description>Hello World Home Description</description>
<description-id>page.helloworldhome.description</description-id>
<template-instance>helloworldhome-three-column</template-instance>
<authentication>none</authentication>
</page>

File : helloworldhome-three-column.xml ( <Alfresco> -> tomcat -> shared -> classes -> alfresco -> web-extension -> site-data -> template-instances )

<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>org/alfresco/demo/helloworldhome</template-type>
</template-instance>

File : helloworldhome.ftl ( <Alfresco> -> tomcat -> shared -> classes -> alfresco -> web-extension -> templates -> org -> alfresco -> demo )

This is just a test page. Hello World!

File : helloworldhome.properties ( -> messages )

page.helloworldhome.title=Hello World 
page.helloworldhome.description=Hello World Home Description

File : Rename the custom-slingshot-application-context.xml.sample to custom-slingshot-application-context.xml ( <Alfresco> -> tomcat -> shared -> classes -> alfresco -> web-extension )
Then define the following bean:

<bean id="org.alfresco.demo.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco.web-extension.messages.helloworldhome</value>
</list>
</property>
</bean>

Note : After completing these steps Restart Server… and go localhost:8080/share/page/helloworldhome

To add share header and footer modify file : helloworldhome.ftl ( <Alfresco> -> tomcat -> shared -> classes -> alfresco -> web-extension -> templates -> org -> alfresco -> demo )

<#include "/org/alfresco/include/alfresco-template.ftl" />
<@templateHeader></@>
<@templateBody>
<@markup id="alf-hd">
<div id="alf-hd">
<@region scope="global" id="share-header" chromeless="true"/>
</div>
</@>
<@markup id="bd">
<div id="bd">
<h1>
This is just a test page. Hello World!</h1>
</div>
</@>
</@>
<@templateFooter>
<@markup id="alf-ft">
<div id="alf-ft">
<@region id="footer" scope="global" />
</div>
</@>
</@>

Link this page (helloworldhome) in share header
File : share-header.lib.js ( <Alfresco> -> tomcat -> webapps -> share -> web-inf -> classes -> alfresco -> site-webscripts -> org -> alfresco -> share -> imports )
Go to at generateAppItems() function and add this code.

{
id: "HEADER_CUSTOM",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_CUSTOM",
label: "My Menu",
targetUrl: "helloworldhome"
}
}

--

--