cancel
Showing results for 
Search instead for 
Did you mean: 

Share - Customize Description of a document

jackjm
Champ in-the-making
Champ in-the-making
Hello all

I have noticed that if a user enters a large description; the default view (when viewing all the documents in a space) shows all of it. I would like to add some logic that checks if the description is greater than say 200 characters; only the first 200 characters are displayed.

I am only just getting used to customizing share-documentlibrary-config.xml; but it seems I have to write additional logic to be able to perform this check. Any suggestions or links to if someone has attempted something along this line before?

As always, thanks a lot for all your input.
2 REPLIES 2

jordiv
Champ on-the-rise
Champ on-the-rise
You can achieve this using metadata templates and Javascript renderers.

Code would be something similar to this:


share-config-custom.xml

    <config evaluator="string-compare" condition="DocumentLibrary">
       
        […]
       
        <metadata-templates>
            <template id="default">
                <line index="10" id="date" view="detailed">{date} {size}</line>
                <line index="20" id="myDescription" view="detailed">{myDescription}</line>
                <line index="30" id="social" view="detailed">{social}</line>
            </template>
        </metadata-templates>
       
        […]
    </config>
    <config evaluator="string-compare" condition="DocLibCustom">
        <dependencies>
            <js src="/js/myDescription.js" />
        </dependencies>
    </config>

Then in tomcat/webapps/share/js/ create the myDescription.js file:

(function() {
   var $html = Alfresco.util.encodeHTML,
      $isValueSet = Alfresco.util.isValueSet;

   if (Alfresco.DocumentList)
   {
      YAHOO.Bubbling.fire("registerRenderer",
      {
         propertyName: "myDescription",
         renderer: function myDescription_renderer(record, label)
         {
            var jsNode = record.jsNode;
            var desc = "";
            if(jsNode.properties.description != undefined) {
                desc = jsNode.properties.description.substring(0, 200);
                if(jsNode.properties.description.length > 200) desc += " […]";
            }
            return '<span class="item">' + desc + '</span>';
         }
      });
   }
})();


Cheers,
Jordi

jackjm
Champ in-the-making
Champ in-the-making
Thank you very much Jordi; works great.