cancel
Showing results for 
Search instead for 
Did you mean: 

Markup directive in head.ftl haven't been processed

webdesigner
Champ in-the-making
Champ in-the-making
Hi,

as asked by Dave Drapper in the comment:
http://blogs.alfresco.com/wp/developer/2012/05/22/customizing-share-javascript-widget-instantiation-...

this topic is created.


1. Alfresco Version
I'm running Alfresco 4.1.1.9 (Un upgrade to 4.1.2 is planed, but later)

2. Are you creating and deploying an extension module? (and are you sure it’s deployed successfully?)
Yes, all other <@markup> directives have been processed properly, only directives within of *.head.html don't work

3. Are you targeting the correct <@markup> elements and are you using the right actions?

Here my code (my extension are packaged into the JAR and copied to WEB-INF/lib by deployment):

1. Extension module in /alfresco/web-extension/site-data/extensions/my-extension.xml

<extension>
   <modules>
      <module>
            <id>My Share Extensions</id>
           <auto-deploy>true</auto-deploy>
          <customizations>
             <customization>               
                  <targetPackageRoot>org.alfresco.components.comments</targetPackageRoot>               
                  <sourcePackageRoot>my.extensions.comments</sourcePackageRoot>
              </customization>       
          </customizations>
      </module>
   </modules>
</extension>

2. Patch in the CORE web script: /share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/comments/comments-list.get.head.ftl

<#include "../component.head.inc">
<!– Comments List –>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/comments/comments-list.css" />
<@script type="text/javascript" src="${page.url.context}/res/components/comments/comments-list.js"></@script>
<!– PATCH START custom-includes –>
<@markup id="commnts-list-custom-includes">
</@markup>
<!– Patch end –>

3. Custom webscript extension in /alfresco/webscripts/my/extensions/comments/comments-list.get.head.ftl

<@markup id="commnts-list-custom-includes-impl" target="commnts-list-custom-includes" action="replace" scope="global">
   <@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/css/my-comments-list.css" />
</@markup>

After deploying to Alfresco generated HTML for comments-list component doesn't contain a custom include.

In Log I see this warning:
2013-02-03 06:47:01,002  WARN  [extensibility.impl.ExtensibilityModelImpl] [http-8080-exec-23] The 'replace' action was attempted to used when defining the base model by directive:ID: commnts-list-custom-includes-impl, ACTION:replace

And in generally (as improvement idea), I think this markup:

<@markup id="custom-includes">
</@markup>

would be very useful at the end of every *.head.ftl, because it's a very simple but flexible way to add own customisations to Share components, without patching the core files everywhere where this component is  included.

Best regards
Vitali
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

I have never tried to target a .head.ftl with a customization, since it is always easier for me to simply add a JS / CSS dependency in the <customization>-tag, like David outlined in <a href="http://blogs.alfresco.com/wp/ddraper/2012/01/04/extensibilty-updates-roundup/">this blog post</a>. Since you're not doing anything different (and .head.ftl are hopefully going to be dying out in one of the next releases), I would advise you to use this approach, save yourself the need to modify core code and be upgrade-safe.

Regards
Axel

webdesigner
Champ in-the-making
Champ in-the-making
Hello Alex,

this approach works!

Thanks for hint, module dependencies are of course much better as patches in the core files.

Regards
Vitali

ddraper
World-Class Innovator
World-Class Innovator
The main thing to be aware of is the following…
.head.ftl files are processed in the same way as .html.ftl files. It is possible to extend a .head.ftl file (although not-advisable from 4.2 onwards as they're deprecated) but not via <@markup> directives… essentially anything you add in a custom .head.ftl file will be appended to the <head> element of the HTML page (the reason for this is that the content of a .head.ftl file can only go into one place - the <head> element - the content in a .html.ftl file can be targeted at different sections of the HTML page).

Your suggestion for the custom includes isn't really relevant going forwards… you can append, prefix, remove or replace any imports defined in a .html.ftl file and there are now consistently named <@markup> directives across all the Share WebScripts for you to do this. Since .head.ftl files are being removed and don't support <@markup> directives there is no point in adding this additional extension point.

I hope that explains everything,

Regards.
Dave

webdesigner
Champ in-the-making
Champ in-the-making
Hi Dave,

thanks for your answer. I think the best way for custom includes is using of <dependencies> tag in customisation packages (as Axel suggested in the previous post). t doesn't require any core changes and is very flexible.

So no patches of head files anymore…

Best regards
and thanks for your help.

Vitali
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.