RSS

Custom Metdata in Alfresco Share

03 Jul
I recently setup Alfresco 3.0 Community for internal usage. I was able to get everything running with LDAP and NTLM integration. The Share application however, needed some tweaking as I had added some custom types and Share does not display custom metadata as of 3.0. So instead for going for the 3.1 Preview, which has forms support I decided to stick to the more stable 3.0 and tweak it. In this post I will describe the changes required.

I recently setup Alfresco 3.1 Community for internal usage. I was able to get everything running with LDAP and NTLM integration. The Share application however, needed some tweaking as I had added some custom types and Share does not display custom metadata as of 3.1. So instead for going for the 3.2 Preview, which has forms support I decided to stick to the more stable 3.0 and tweak it. In this post I will describe the changes required. Please note that this post applies only to Alfresco 3.1 Community. Alfresco 3.2 adds forms support which provides support for any custom metadata to be displayed/edited with very minimal configuration.

First you need to tell the Web Framework to show your custom type by adding the following in web-framework-config-custom.xml in the web-extension folder.


<config evaluator=”string-compare” condition=”my:customtype”>
<form>
<field-visibility>
<show id=”my:prop1? />
<show id=”my:prop2? />
</field-visibility>
<appearance>
<field id=”my:prop1? />
<field id=”my:prop2? />
</appearance>
</form>
</config>

Now edit share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-info.get.html.ftl and add appropriate HTML for displaying the custom metadata as below


<div class=”info-section” id=”${args.htmlid}-customtype”>
<div class=”heading”>Custom Metadata</div>
<div class=”info”>
<span class=”meta-label”>Prop1:</span>
<span id=”${args.htmlid}-prop1? class=”meta-value”></span>
</div>
<div class=”info”>
<span class=”meta-label”>Prop2:</span>
<span id=”${args.htmlid}-prop2? class=”meta-value”></span>
</div>
</div>
</div>

Next, modify share/components/document-details/document-info.js to display the additional metdata. This needs to be done in the onDocumentDetailsAvailable function as follows


if (!docData.customtype)
{
var customTypeDiv = Dom.get(this.id + “-customtype”);
customTypeDiv.innerHTML = “”;
}
else
{
Dom.get(this.id + “-prop1?).innerHTML = $html(docData.customtype.prop1);
Dom.get(this.id + “-prop2?).innerHTML = $html(docData.customtype.prop2);
}

We have now made the changes in Share to display the custom metadata. But the data will still not be displayed because Share gets the data from a Web Script which also needs to be modified. To do that modify the file alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js as follows
Add the following lines inside the <#assign tags> block.


<#if item.customtype?exists>
“customtype”:
{
“prop1″: “${item.customtype.prop1}”,
“prop2″: “${item.customtype.prop2}”
},

 

Now modify the alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js file and add the following just before the items.push(…) line


var customtype = null;
if (assetType == “document” && asset.type == “{myuri}customtype”)
{
var prop1 = “”;
if (asset.properties["{myuri}prop1"])
{
prop1 = asset.properties["{myuri}prop1"];
}
var prop2 = “”;
if (asset.properties["{myuri}prop2"])
{
prop2 = asset.properties["{myuri}prop2"];
}
customtype =
{
prop1:prop1,
prop2: prop2
}
}

This should display the custom metdata in Share when you click on a document and go to the detail page. In next post I will cover how you can display the metdata in the Edit Metadata screen and also save any changes.

Advertisements
 
7 Comments

Posted by on July 3, 2009 in Alfresco

 

Tags: , ,

7 responses to “Custom Metdata in Alfresco Share

  1. Tibor Burda

    July 7, 2009 at 5:35 am

    Thanks!

    It helped me a lot!

     
  2. Amarendra Thakur

    November 11, 2009 at 1:14 pm

    gr8 Article,

    I Hope you remember me.

    I am creating a space in alfresco and assigning Users to that space by applying association through my custom model.xml.
    Now i also have to display the “Status” of the user (Active or Inactive).something like below

    userMembershipInfo

    Status
    d:text
    true

    Member List

    false
    true

    cm:person
    false
    true

    But the problem is that in the above case,the assoc “km:spaceMembers” and and the property “km:memberStatus” are not bind to each other,they are rather individual

    I want to display the users and their status in that space.

    Can you tell me how can i do that

    Thanks & Regards

    Amarendra Thakur

     
  3. Amarendra Thakur

    November 11, 2009 at 1:15 pm

    userMembershipInfo

    Status
    d:text
    true

    Member List

    false
    true

    cm:person
    false
    true

     
  4. Atish Dipankar

    January 6, 2010 at 11:40 am

    Hi Aniruddh,

    Thanks, for this help, i want toask u want thing that i want to customize alfresco share particulary i want to add a advanced search option where i can put my custom metadata in that and make it searchablae thorugh share UI.

    Can you please put a light on this?

    Thanks,
    Atish

     
  5. Milad

    February 13, 2010 at 4:07 pm

    Hi,

    I have followed your instructions, and it works well, but i badly need your next post regarding this inorder to edit and put data for those fields…

    waiting for your soon reply on this matter…

     
    • aniruddhchitre

      June 14, 2010 at 7:25 pm

      Milad,
      I am really sorry I could not post further. However, you can now try Alfresco 3.3 Community. The Share application in it supports custom meta data editing.

       
  6. Kelley

    May 3, 2013 at 12:27 pm

    WOW just what I was searching for. Came here by searching for network

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: