Manage Links in Alfresco

In Alfresco we have a concept of Links which acts like shortcuts within repository. For instance we have a folder which we need to show in two different hierarchies creating duplicate copy is not a solution to achieve that because it will be difficult to keep both copy in sync.

So, Links comes to rescue in that case. We can create a link of folder or content and make it available wherever we want to place. By this we can make it available within multiple hierarchies in same repository.

Here is how it looks like in alfresco User Interface.

Folder Link in Alfresco Share

Folder Link in Alfresco Share

There are basically two type of links related types defined in out of box application content model of alfresco.

FileLink

<type name=”app:filelink”>

<title>File Link Object</title>

<parent>cm:link</parent>

</type>

Folder Link

<type name=”app:folderlink”>

<title>Folder Link Object</title>

<parent>cm:link</parent>

</type>

Both of them are extending basic Link type defined in the out of box Alfresco content model.

  <type name="cm:link">

         <title>Link Object</title>

         <parent>cm:cmobject</parent>

         <properties>

            <property name="cm:destination">

               <title>Link Destination</title>

               <type>d:noderef</type>

               <mandatory>true</mandatory>

            </property>

         </properties>

      </type>

We can also create links using javascript.

Here is the script to create link

var pr = [];

//Setting properties in Array to associate with link node during creation

pr["cm:name"] = "abcurl";

//NodeRef of destination folder for which we are creating link this is normally retrieved by searching //within repository but here for sake of simplicity it is hard coded

pr["cm:destination"] = "workspace://SpacesStore/429006d5-9f76-4855-aa23-654b76788759";

pr["cm:title"] = "abc.logurl";

pr["cm:description"] = "abc.logurl descitpion";

//Creating Folder link with aspect pr and name “abcurl”

linkNode = space.createNode("abcurl", "{http://www.alfresco.org/model/application/1.0}folderlink", pr);

//save created link node

linkNode.save();

To create content link you need to set type accordingly in above code.

Hope this will help you to meetup some of the requirements in your alfresco setup. Most of the times this is missed because of lack of documentation related to this.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *