Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How to create Search filter for Folder

Avatar

Level 7

Suppose In my DAM I have two folder /content/dam/us/en and /content/dam/us/de I want to create option filter predicate for /content/dam/us/en which should not reflect on /content/dam/us/de DAM asset path

 

qandaCapture.PNG

 


Question

 

1. Can we add filter predicate for just  /content/dam/us/en dam path?

2. Can we add filter different for  /content/dam/us/en and  /content/dam/us/de which should not reflect in one another?

9 Replies

Avatar

Community Advisor

Hello @Ronnie09 

 

We do not seem to have a conditional show/hide option via Serach Forms UI.

Can you please try using renderconditions? Append them via CRXDE.

 

Caution: The render conditions might be deleted, if someone edits the Serach Form from UI


Aanchal Sikka

Avatar

Level 7

Hi @aanchal-sikka 

Do you have any sample how can I workout via renderconditions?

Avatar

Community Advisor

@Ronnie09 

 

 

{
	"jcr:primaryType": "nt:unstructured",
	"listOrder": "101",
	"metaType": "tags",
	"fieldLabel": "Tags 1",
	"sling:resourceType": "cq/gui/components/coral/common/admin/customsearch/searchpredicates/tagspredicate",
	"granite:rendercondition": {
	"jcr:primaryType": "nt:unstructured",
		"sling:resourceType": "granite/ui/components/foundation/renderconditions/and",
		"dms7feature": {
			"jcr:primaryType": "nt:unstructured",
			"expression": "${!granite:containsIgnoreCase(header['Referer'], 'library')}",
			"sling:resourceType": "granite/ui/components/coral/foundation/renderconditions/simple"
		}
	}
}

Please try above config

I have tried on Tabs predicate, the filter is not displayed, but its title is available.

The condition checks if the request is made from a folder that have 'library' in it.

 

When search is done from a folder, the request for filter section has Referer like :

aanchalsikka_0-1695908702503.png

 


Aanchal Sikka

Avatar

Level 7

Hi @aanchal-sikka 

I have created new option predicate filter ECO I don't want to show to /content/dam/us/en and other site only visible to /content/dam/us/de. This is also  achievable via render condition? I am ok to do via crx/de

Ronnie09_0-1695907117220.png



I tried adding simple render condition but not working

Ronnie09_2-1695907375942.png

 

 



Avatar

Community Advisor

@Ronnie09 

I have updated my previous reply. It needed corrections. Please check


Aanchal Sikka

Avatar

Level 7

@aanchal-sikka 
It is not working
As Stated I have added same but for me Header Referer is different. I am using AEM Cloud

Ronnie09_0-1695912173661.png


Below is the change as suggested by you

Ronnie09_3-1695912360758.png

 

 

Ronnie09_2-1695912260365.png

 

Avatar

Community Advisor

@Ronnie09 

 

The Referer without FOlder path is created when we refresh the search page.

However, if you go to a Folder and then click filter, the folder info is present in Referer.

 

I hope the ! (NOT) operator in the expression can help achieve the default and the folder specific behaviour


Aanchal Sikka

Avatar

Level 7

@aanchal-sikka 
Got it ... It is working for tag Predicate but not option predicate

Style - TAG PREDICATE
Eco - OPTION PREDICATE

Ronnie09_1-1695913666831.png

 

 

Avatar

Level 7

@aanchal-sikka 
Thanks for the config

I tried on OOTB created Option Predicate for those as well it is not working.