'AEM TouchUI Dialog Components: Extend dam/cfm/components/cfpicker with custom filter

Content fragments of different Model Types are saved in the SAME directory without sub-directories.

I know is not ideal, but this is the scenario.

There could be a lot of different content fragments that have different content fragment models, so we have to extend the OOTB single CF Picker

dam/cfm/components/cfpicker

with content fragment model filtering feature and restrict to certain paths. If I add in the dialog component a list of content model types, when I browse to select a content fragment, only show the ones that have the desired content fragment model type.

Something like:

<fragmentPath
    jcr:primaryType="nt:unstructured"
    sling:resourceType="dam/cfm/components/cfpicker"
    name="./fragmentPath"
    fieldDescription="Path to the Content Fragment to display."
    fieldLabel="Content Fragment"
    emptyText="Enter or select Content Fragment"
    pickerTitle="Select Content Fragment"
    modelType="model1, model2, model3" <---- //selection should be filtered by these model types
    rootPath="/content/dam"/>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source