AnsweredAssumed Answered

Markup directive in head.ftl haven't been processed

Question asked by webdesigner on Feb 3, 2013
Latest reply on Feb 4, 2013 by ddraper
Hi,

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

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

Outcomes