Path Field - how to restrict available types? | Community
Skip to main content
Level 4
February 1, 2023
Solved

Path Field - how to restrict available types?

  • February 1, 2023
  • 1 reply
  • 1163 views

I have a pathfield where I am allowing the user to select one or more templates in my site:

 

<templates jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/pathfield" emptyText="Optional template(s) to filter results by" fieldDescription="One or more templates which optionally filter the returned results." fieldLabel="Templates" filter="hierarchyNotFile" multiple="{Boolean}true" name="./templates" rootPath="/conf/mysite/settings/wcm/templates"/>

 

The idea is that I want the content author to be able to select one or more templates that I will perform some logic off of.

 

Is there a way that I can restrict this selection to only instances of cq:Template? e.g., I do not want the user to be able to select the "Initial" or "Structure" nodes, only the root page template nodes.

 

 

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 arunpatidar

You can use granite/ui/components/coral/foundation/form/pathbrowser and create your own predicate to allow only cq:templaes

Example, I created predicate for svg images

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/core/predicate/SVGImagePredicate.java 

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
February 1, 2023

You can use granite/ui/components/coral/foundation/form/pathbrowser and create your own predicate to allow only cq:templaes

Example, I created predicate for svg images

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/core/predicate/SVGImagePredicate.java 

Arun Patidar