cancel
Showing results for 
Search instead for 
Did you mean: 

custom dashlet displaying MS word press release improperly

aatamer
Champ in-the-making
Champ in-the-making
Based on the Shariff ebook, I created a custom dashlet to display press releases.  I stuck a couple of MS Word documents into the space but the text displayed in the press release area is:

CF999-00482.doc
�� ࡱ �����������������>� ��� � …

The title is indeed CF999-00482, but all the question marks are not part of the document.

The dashlet that is displaying the document is below, customized a little from the ebook

<table>
<#assign l_space = companyhome.childByNamePath["Corporate/News and Announcements"]>
<#list l_space.children as doc>
<#if doc.isDocument>
<tr>
<td>
<a class="title" href="/alfresco/${doc.url}">${doc.properties.title}</a></td>
</tr>
<tr>
<td style="padding-left:8px">
<#if (doc.content?length > 500)>
<small>${doc.content[0..30]}…</small>
<#else>
<small>${doc.content}</small>
</#if>
</td>
</tr>
<tr><td> <HR> </td></tr>
</#if>
</#list>
</table>

What could it be? Thanks.
5 REPLIES 5

aatamer
Champ in-the-making
Champ in-the-making
Yes, when you hit the part of the MS Word doc file outside of the icon area within My Spaces, you can get a preview of the file in plain text. That's what I need.

I am not sure what the myspaces-webscript.jsp dashlet calls, but I found the
myspaces_preview_panel.ftl which appears to be the file used in the "My Spaces" bubble up preview.

Here's the first block of code of that file:

<#assign isImage=node.isDocument && (node.mimetype = "image/gif" || node.mimetype = "image/jpeg" || node.mimetype = "image/png")>
<table width="690" cellpadding="2" cellspacing="0" border="0" onclick="event.cancelBubble=true;">
   <tr>
      <td>
         <div class="spacePreview">
            <#if node.isDocument && !isImage>
               <#assign c=cropContent(node.properties.content, 2048)>
               <#if c?length != 0>
                  ${c?html?replace('$', '<br>', 'rm')}<#if (c?length >= 2048)>…</#if>
               <#else>
                  Sorry, no preview currently available for this document.
               </#if>


so I snipped out this section and put it into my custom FTL.  I got this error message

Error during processing of the template 'Expression cropContent is undefined on line 20, column 14 in alfresco/templates/press_releases.ftl.'. Please contact your system administrator.

According to the Alfresco Wiki, the function cropContent is part of the default model for Templatenodes.  What else needs to be done?

kevinr
Star Contributor
Star Contributor
cropContent method was only added relatively recently i think. You might need a newer build.

Kevin

louise
Champ in-the-making
Champ in-the-making
So, is it in 2.9C or 3.x only?

kevinr
Star Contributor
Star Contributor
I had a quick look in the codebase, in Alfresco 2.9 cropContent() was only available to the freemarker template that builds the pop-up dialog that you mention - it is not available to other templates. This has been rectified in latest 3.0 code (i.e. a much more recent build) and it now available to all templates in the repository.

Thanks,

Kevin

javauser007
Champ in-the-making
Champ in-the-making
Hi aatamer,
I'm also facing the same problem. It is working fine with .txt files but with office documents i'm facing the
same kind of problem. did you resolve this one? if yes, can you tell me the changes were needed for the same.