Expand my Community achievements bar.

SOLVED

Path Field - how to restrict available types?

Avatar

Level 5

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.

 

dylanmccurry_0-1675268759393.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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/... 



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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/... 



Arun Patidar