cancel
Showing results for 
Search instead for 
Did you mean: 

Share extensibility with template

lotharmärkle
Champ in-the-making
Champ in-the-making
Hello,

while exploring the nice 4.x features for share extensibility - I would like to replace a page template for a specifc site only. From the blogs here http://blogs.alfresco.com/wp/ddraper/ and the docs here http://docs.alfresco.com/4.0/topic/com.alfresco.enterprise.doc/concepts/Share-Extensibility-Intro.ht... it seems that it is only possible to replace <region/> directives.

To clarify the requirements…since 4.x the document-details page uses  a new layout showing just the document preview and the document actions list. To view the custom properties of the document you have to scroll down. This is (user-level point of view) not very usage-friendly, and there is also not much place left to customize the form. Also, if scrolling down to view the properties, the preview goes away.

I tought it would be best to replace the template of the document-details page, to show the preview, properties form and actions side by side(very much like in 3.4.x).

So is it possible to replace a template for a page on a specific site completly - not just component-bindings? And if not, how could I add it to org.springframework.extensions.surf.extensibility.*?

thanks,
  lothar
3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator
I think that you have a couple of options here…

Firstly you could override the Template-Instance definition for the document-details page (this is found in "share\WEB-INF\classes\alfresco\site-data\template-instances\document-details.xml") by defining your own TemplateInstance configuration file and placing it under the "web-extension" path, e.g. "share\WEB-INF\classes\alfresco\web-extension\site-data\template-instances" and then map to your own Template freemarker file.

This would give you complete flexibility over the template - however the the disadvantage with this approach would be that you would have to maintain the <region> definitions for all the <components> that you wish to keep.

The second option might be to investigate either adding in additional content via Sub-Components (see http://blogs.alfresco.com/wp/ddraper/2011/07/22/how-to-add-content-to-an-alfresco-share-page/) or by additional regions (http://blogs.alfresco.com/wp/ddraper/2011/08/12/customizing-alfresco-share-freemarker-templates/). The benefit of these approaches would be that you wouldn't need to keep you local Template in-sync with any changes made to the base template.

Unfortunately, looking at the content you're trying to modify you're somewhat limited by the use of the YUI grid CSS that is splitting the page into a 2/3 - 1/3 column split. It really depends on your exact design requirements for displaying the custom properties.

Regards,
Dave

lotharmärkle
Champ in-the-making
Champ in-the-making
Thank you for your thoughts and suggestions on this.

So overriding via web-extension would allow to replace the template without touching the source file - great! I could add a switch and include the ootb template.

Is there a way to combine this with the extensibility mechanism, so that it would only be active based e.g. on the site name? All other sites would then still use the ootb template.

Another idea would be to remove all regions on the document-details using the extensibility mechanism with <@region action="remove"> and to replace/extend the last region of that document-details (custom-doclib) with the new template layout. But I am not sure if the before-removed-regions will be available…

All a litte complicated as I just would like to change the structure and placement of the regions on the page, not the region contents itself.

Is this kind of customization on the extensinibilty mechanism roadmap? Maybe something like

<template-customizations>
  <template-customization>
      <targetPackageRoot>org.alfresco</targetPackageRoot>
      <sourcePackageRoot>org.acme.templates</sourcePackageRoot>
   </template-customization>
</template-customizations>

which would mean that this will replace the template org.alfresco.document-details.ftl with org.acme.templates.document-details.ftl.

Regards,
  lothar

ddraper
World-Class Innovator
World-Class Innovator
When you create your overridden document-details Template-Instance configuration file and the associated FreeMarker template file you could make use of the <@markup> directive which works in a similar way to the <@region> directive but is just used to demarcate specific sections of a template for extension (this directive is mentioned briefly at the end of this blog: http://blogs.alfresco.com/wp/ddraper/2011/08/12/customizing-alfresco-share-freemarker-templates/). This directive has the same actions ("before", "after", "remove", "replace") as the <@region> directive. If you can use this directive in your custom template and then define a new an extension module to change the default values and use an evaluator so that the changes only apply to certain sites.

Part of the problem with removing all the regions as you've suggested is that you'll still be left with the basic layout defined through the <div> elements containing the YUI grid-layout CSS classes. But if you wrap these elements with <@markup> directives then you'll have full control of the layout of the page.

We not used too many <@markup> directives throughout the Share code-base yet because we weren't sure where they'd be useful. I'm hoping that we can start to introduce this directive more (along with others) to give complete control over the output of Share but I can't guarantee when this might happen.

Regards,
Dave