cancel
Showing results for 
Search instead for 
Did you mean: 

How to add custom filters to Share/Repository

webdesigner
Champ in-the-making
Champ in-the-making
Hello,

I need to add custom filters in the navigation panel for Sites and Repository (similar to All Documents, I'm editing etc. but searching for custom metadata).

I implemented a new Share extension for filter - component (I mean <region-id>filter</region-id>) and managed to display custom filters.
I use BaseFilter 
new Alfresco.component.BaseFilter("Alfresco.MyCustomFilters", …

so by clicking to my custom filter, the doc list will be refreshed with parameter filter=<new filter value>
E.g.: http://localhost:8080/share/page/site/test/documentlibrary#filter=myCustomValue%7C&page=1

But how to extend the Repository logic, that loads the filtered data for the document list?

I figured out, that the filters logic is implemented here:
alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/filters.lib.js

in the method:
Filters.getFilterParams

case "editingMe":
            filterQuery = this.constructPathQuery(parsedArgs);
            …

I can overwrite this file and add my own code in filters.lib.js, but I want to avoid changing of standard Alfresco files because of further version-update problems.

So the question is:
Is there any way to extend Alfresco to handle custom filter values?

Thanks in advance

Best regards
Vitali
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

currently, there is no easier way to customize or add your own filters to the Repository logic - overwriting the file via the extension method (/tomcat/shared/classes/alfresco/extension/…) is the best way for this particular use case at the moment. If you properly document your changes, you should not be facing any serious upgrade issues - those webscripts tend to be relatively stable between releases.

Regards
Axel

webdesigner
Champ in-the-making
Champ in-the-making
Hi Axel,

thanks for your answer.

I don't think that your proposal with documentation will help in this situation. Just imagine, that you change the Core-file (filters.lib.js) and another extension is doing the same. If both extensions will be deployed (for example as AMP's) into Alfresco one extension will overwrites the changes on Core-files from another.

What is required. is a properly way to add custom filters via configuration, because this is a very common scenario for a DMS system, to filter for custom metadata without leaving the document library view.

Best regards
Vitali

afaust
Legendary Innovator
Legendary Innovator
Hello Vitali,

yes, you are right - in case extensions via AMP or JAR method want to introduce new filters, you need to have some kind of extension hook. Usually, when I modify a core Alfresco source file, I actually implement such a hook myself, even if not using an AMP extension. This is what I then include in proper documentation or even submit as patches to Alfresco, when they themselves have not yet added a feature of their own (e.g. the new Surf / Share Extensibility features, which have already addressed a large part of what I previously had to adapt).

What I outlined on the other hand is the commonly accepted approach for a majority of installations / users that only have a limited business use case to address and do not make use of such extensive extensions (perhaps only Share Extras and some other dashlets). For maintainers of a DMS platform - which I am for a large pharmaceutical company - , this is not enough / suitable at all as you point out.

Regards
Axel