Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

how to validate experience fragment template name in java script or sightly

Avatar

Level 2

how to validate experience fragment template name in java script or sightly.
we have used xffield to select experience fragment.
i have to validate dialog and should allow only experience fragments which is created on particular template

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @Sudarshan1992 

 

Option-1: Ideally for such scenarios, one should separate out these XF in seperate folders. And then use rootPath config, to allow user to pick only from relevant folder.

 

Option-2:

Value of each column in XF picker is returned from a query similar to the one below:

aanchalsikka_0-1685039977644.png

 

OOTB it is not possible to filter XF based on templates. However, there is a workaround.

There is propertyFilter. If the value of this property is false on a page, it won't be returned.

 

You could create your own extended component. Override "propertyFilter" as some other property. And use that property in pages to show/hide them in XF picker. Default values of this property can be copied to pages via templates.

 

Location of propertyFilter "/libs/core/wcm/components/experiencefragment/v2/experiencefragment/cq:dialog/content/items/tabs/items/properties/items/columns/items/column/items/fragmentVariationPath"


Aanchal Sikka

View solution in original post

2 Replies

Avatar

Level 9

Hi @Sudarshan1992 ,

Experience fragments are stored under /content/experience-fragments paths.

Call the service from slightly. In the service class, you can write a query to get all experience fragments under /content/experience-fragments path where cq:template is particular template type. This will return the XF created from specific template.



Screenshot 2023-05-25 at 7.52.16 PM.png

Avatar

Correct answer by
Community Advisor

Hello @Sudarshan1992 

 

Option-1: Ideally for such scenarios, one should separate out these XF in seperate folders. And then use rootPath config, to allow user to pick only from relevant folder.

 

Option-2:

Value of each column in XF picker is returned from a query similar to the one below:

aanchalsikka_0-1685039977644.png

 

OOTB it is not possible to filter XF based on templates. However, there is a workaround.

There is propertyFilter. If the value of this property is false on a page, it won't be returned.

 

You could create your own extended component. Override "propertyFilter" as some other property. And use that property in pages to show/hide them in XF picker. Default values of this property can be copied to pages via templates.

 

Location of propertyFilter "/libs/core/wcm/components/experiencefragment/v2/experiencefragment/cq:dialog/content/items/tabs/items/properties/items/columns/items/column/items/fragmentVariationPath"


Aanchal Sikka