Add new Filter in Alfresco Document Library

Alfresco has a document library which provides an easy to use interface where we can see all files and documents stored within the repository along with other associated actions. With this, users can easily navigate to different documents and files and perform any desired actions such as edit, delete, update and so on. Different types of views are available when viewing the document library.

Out of box available views are as follow.

  • Simple
  • Detailed
  • Gallery
  • Filmstrip
  • Table
  • Audio
  • Media

These views can be customized easily and we can also add new view to existing views.

Now there are also some other features available on document library like filtering of documents. Here we will see in brief about how to add new filter for documents.

Out of box available filters are as follow:

alfrescoFilters

Now here are steps to include new filter.

Step1:

Create a new extension module which will override the existing filter webscript.

For more details on how to create extension module please refer this post.

Extension Module in Alfresco

<customization>

<targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>

<sourcePackageRoot>com.arvixe.components.documentlibrary</sourcePackageRoot>

</customization>

Step2:

Then you need to extend existing filter webscripts (filter.get.js and repo-filter.get.js) to add your filter along with other existing filters

var filters = model.filters;

filters.push(

     {         id: 'newExtension', data: '',
         label: 'link.newExtension'     });

 model.filters = filters; 

Step3:

Then change repository webscript to make it point to your new filters rather than existing one.

To do this simply first copy out of box script lib file (filter.lib.js) in your extension folder

alfresco / templates / webscripts / org / alfresco / slingshot / documentlibrary-v2 / filters.lib.js

case "newExtension":          
  
filterQuery = "+PATH:\"" +parsedArgs.rootNode.qnamePath + "//*\"";              
filterQuery += "+@custom\\:isMatch:\"FALSE\"";               
filterParams.query = filterQuery + filterQueryDefaults;          
     break;

There you go just restart your server and you will be able to see your new filter in document library and will be able to filter based on that.

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 *