cancel
Showing results for 
Search instead for 
Did you mean: 
ddraper
World-Class Innovator
World-Class Innovator

Introduction

The Aikau framework provides a simpler way of creating pages in Share where a page can be declaratively defined as a JSON model in a WebScript. This avoids the necessity to create the XML and FreeMarker files for Surf Pages, Templates and Components.

I've been asked how you would create an Aikau page such that it is available as a site page in Share (e.g. a page that can be added via the Site Customization tooling in Share). So thought it would be worth capturing this information in a blog post. This is one of those interesting use cases where the old and new approaches of Share development intersect...

Background

In Share we use 'pre-sets' configuration to provide default User and Site dashboards. These are XML configurations that define the Surf objects that can be used to 'cookie-cut' new page instances (which are then stored on the Alfresco Repository).

The pre-sets can be found in in this file and the 'site-dashboard' pre-set contains a property ('sitePages') that defines the initial set of pages for each site. Once the site is created a new Surf Page instance is created on the Repository and when you add or remove pages from the site it is this property that is updated (in the instance, not the pre-set).

The 'Customize Site' page lists both the available 'Site Pages' and the 'Current Site Pages' and the list of pages to choose from is defined in the 'share-config.xml' file under the 'SitePages' condition, e.g:

<config evaluator='string-compare' condition='SitePages'>
  <pages>
    <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>‍‍‍‍‍‍‍‍‍‍‍

It's possible to extend this configuration to include additional pages, however the underlying code currently assumes that each page is mapped to a Surf object. This means that if you want to add in an Aikau page to this list then you need to create a Surf Page object (even though it won't actually be used to render the page at all).

Example

Say you want to add in a new Aikau page called 'Example'. You need to create a Share configuration extension that defines the new page (one way of doing this would be to create a 'share-config-custom.xml' file that you place in the 'alfresco/web-extension' classpath).

The file would contain the following XML:

<alfresco-config>
  <config evaluator='string-compare' condition='SitePages' replace='false'>
    <pages>
      <page id='example'>dp/ws/example</page>
    </pages>
  </config>
</alfresco-config>

But you'd also need to create a Surf Page XML file (placed in the  'alfresco/site-data/pages' classpath) containing:

<?xml version='1.0' encoding='UTF-8'?>
<page>
  <title>Example Site Page</title>
  <description>Example of adding a new site page</description>
</page>

Which would result in the following being shown when customizing a site:

The Customize Site page showing an Aikau page. 

5 Comments
blog_commenter
Confirmed Champ
Confirmed Champ
Hi. I have a problem with hybrid page. I pass arguments for /my-new-page and when I try to access /hdp/ws/my-new-page, the arguments provided by URL are null. If I construct this arguments in page /hdp/ws/my-new-page, i.e., give for XML instead of only /my-new-page, /hdp/ws/my-new-page, but with this, I get the page without template. Any solution? Thanks in advance.
ddraper
World-Class Innovator
World-Class Innovator
There's no need to post the same question on two different blog posts (you've posted an identical question here: https://www.alfresco.com/blogs/developer/2013/02/21/simple-page-creation-in-share/).
blog_commenter
Confirmed Champ
Confirmed Champ
Does configuring a dashlet use similarly named structures? For example, is there a condition='SiteDashlets' and perhaps within  be identified as a dp/ws/sitappsDashlet?



I haven't been able to find the right configuration to make my dashlet appear in site configuration.

Using alfresco community 5.1 EA 201509
ddraper
World-Class Innovator
World-Class Innovator
@Stuart - In order to make a WebScript be used as a dashlet you need to configure the family element in the descriptor file to be either 'dashlet', 'site-dashlet' or 'user-dashlet' (depending upon whether you want it to be available for use on all, site or user dashboards).
maxdykhno
Champ in-the-making
Champ in-the-making

Hi, Dave!
I faced with the problem when I, using share module extension approach, added page as you described so that I can manage module in share/page/modules/deploy. So when I switch on the module I can add my page to any site as you described. But the problem occurs when I switch off the module - site still have this page available. Do you have any suggestions how to solve it? Thanks in advance!