This week’s How-to will explain you how to add filters in the Alfresco Share’s Document Library in order to optimize your search logic.
Normally we use Search or Advanced Search to get the desired results. How about a having a filter in document library tool bar to filter the results with name, title, content or even tags?
Search or Advanced Search gives you results in a separate page, not in document library, you won’t have the same feel as document library and you cannot search in a specific folder. Some time we may want filter results that we get suing filters like document I am editing, favourites etc. This filter is faster than normal search as it searches only in particular location. For the people those want to have in-place filter/search in document library that filter the document or folders with entered key word, below is the procedure how we can achieve this.
First we need to add a text field control and filter button to be placed in document library where we have upload button, for this edit documentlist_v2.lib.ftl to have a text field to capture the filter term and button for filter.
Once we have the text field and button ready we need to add events to capture the search term on button click or pressing enter/return key. Edit documentlist-min.js to add the handler. In this handler add the logic to update filer with a custom filer Id, so you can handle it in search webscript.
We need to modify the search logic to add our filter term for filtering results in all cases that is even with existing filters. Edit filters.lib.js, doclist.lib.js to read the filter and add to search query to return results with filter.
Make sure that you have overriding files in shared location to separate you customizations from OOB files.