cancel
Showing results for 
Search instead for 
Did you mean: 

show type of document in share

mrksjs
Champ on-the-rise
Champ on-the-rise
hello.

is there a way to show the title of a (custom) document-type in share?

im not speaking of the mimetype, i want to be able to see which type a document has.
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

you can implement a custom renderer (see <a href="http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fdoclib-web-...">the DocLib extension options</a>) to look at the content type (which is available at runtime) and generate a label for this to display in the document library.

Regards
Axel

mrksjs
Champ on-the-rise
Champ on-the-rise
Thank you Axel for pointing me in this direction!


I was able to display the type of a document by doing the following steps:


create an evaluator in custom-slingshot-application-context.xml

<bean id="evaluator.doclib.action.customDocument" parent="evaluator.doclib.action.nodeType"> 
   <property name="types"> 
      <list> 
         <value>cm:content</value>
      </list> 
   </property> 
</bean>



edit share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibCustom">  
   <dependencies>  
       <js src="/modules/hasCustomType.js" /> 
   </dependencies>
</config>

<config evaluator="string-compare" condition="DocumentLibrary">  
   <metadata-templates>
      <template id="isCustomType">
         <evaluator>evaluator.doclib.action.customDocument</evaluator>
         <line index="10" id="date" view="detailed">{date}{size}</line>
         <line index="20" id="type" evaluator="evaluator.doclib.action.customDocument">
          {hasCustomType}
         </line>
         <line index="30" id="description" view="detailed">{description}</line>
      </template>
    </metadata-templates>
</config>




create hasCustomType.js and put it in /ALFRESCO/tomcat/webapps/share/modules/

<javascript>
/*************************************************************************************                                 
                  TYPE
                                           EXTENSION                                        
*************************************************************************************/
(function()
{
/**
* Alfresco Slingshot aliases
*/
var $html = Alfresco.util.encodeHTML,
  $isValueSet = Alfresco.util.isValueSet;

if (Alfresco.DocumentList)
{    
   YAHOO.Bubbling.fire("registerRenderer",
   {
      propertyName: "hasCustomType",
     
      renderer: function type_renderer(record)
      {
         var jsNode = record.jsNode;       
         var properties = jsNode.properties;
         var html = "";

         var typestr = jsNode.type;
         
         html = '<span class="item">' + "type = " + '<b>' + this.msg(typestr) + '</b></span>';
          
         return html;
     }
  });
}
})();
</javascript>


have to mention that it will show the type for every document of cm:content, not only custom/subtypes.
but if somebody would need that, the js is pretty self-explanatory.


thanks again! Smiley Wink

supriya_verma
Champ in-the-making
Champ in-the-making

Hello Mrkrjs_,

Could you please let me know where you kept your property file. As for me I am getting value as cm:content/cm:folder as Type and not the expected one as 'Content'/'Folder'. I am using ACS 5.2

Also I tried another approach ,customized documentlist-view.table.js as we need to show document type column in only Table view. Added the below code in renderCellThumbnail method. But again type is displaying as cm:content/cm:folder , its not picking the value from property file.

Alfresco.DocumentListTableViewRenderer.prototype.renderCellThumbnail = function DL_SVR_renderCellThumbnail(scope, elCell, oRecord, oColumn, oData)
{

var temp = oRecord.getData();
var node = temp.jsNode;
var type = node.type;
type=type.replace(":", "-");
node.properties['cm:type']= scope.msg(type);

Tried with this.msg(type) , but it is throwing error as this.msg is not found

Added the type column in share-documentlibrary-custom.xml in jsonconfig of table renderer view.

Please help me to find the correct path of property file.

Thanks in advance