Search code examples
alfrescofreemarkeralfresco-share

Customize RSS dashlet alfresco - feed.utils.ftl


I'm new to freemarker.

I wan't to add more options in the config of the RSS dashlet and use it's value to decide if for example the title of an RSS item should be hidden.

I've found the file feed.utils.ftl which is responsible to show the title.

<#macro renderItem item target="_self">
<div class="headline">
<#if item.image??>
   <img align="left" src="${item.image}" alt="" style="padding-right:10px"/>
</#if>
   <h4>
      <#if (item.link?exists)>
        <a href="${item.link}" target="${target}" class="theme-color-1">${item.title}</a>
      <#else>
        ${item.title}
      </#if>
   </h4>
   <p>${item.description}</p>
<#if item.attachment??>
   <div><img src="${url.context}/res/images/filetypes32/${item.attachment.type}.gif"/><a href="${item.attachment.url}">${item.attachment.name}</a></div>
</#if>
   <br />
</div>
</#macro>

There's a corresponding js file, feed.utils.js. I thought I could pass an argument from there to the ftl, for example "model.showTitle". But it has no effect.

The ftl is actively using properties of "item" so I thought maybe I can add my own property to it, but I'm unable to find where these objects are passed to the ftl. Is the macro used to include these?


Solution

  • If you look in share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets you'll find the web script files that implement the RSS dashlet. They are the files that start with rssfeed.

    The rssfeed.get.js file is the server-side JavaScript controller for the dashlet.

    If you were to add a line in that script's main function to set model.showTitle, you could access that value from the script's freemarker template.

    The freemarker file that implements the dashlet is rssfeed.get.html.ftl.

    One way to properly override either of these files is to copy them to web-extension and then the exact same package structure below that. Then you can make whatever changes you want without worrying about problems caused by changing the files distributed with Alfresco.

    The latest, best approach would be to create a Share Module extension and override the files as part of that, but the copy-and-change approach to overriding is easiest.