how to validate experience fragment template name in java script or sightly | Community
Skip to main content
Level 2
May 25, 2023
Solved

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

  • May 25, 2023
  • 2 replies
  • 802 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

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:

 

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"

2 replies

Vaibhavi_J
Level 7
May 25, 2023

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.



aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
May 25, 2023

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:

 

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