Best approach to show up pages at different levels in component : AEM 6.2 | Community
Skip to main content
cquser1
Level 7
February 19, 2017
Solved

Best approach to show up pages at different levels in component : AEM 6.2

  • February 19, 2017
  • 4 replies
  • 3113 views

Hi All,

The requirement is that the user should be able to select level2/level3 pages from the authoring dialog.If the page hierarchy is something like /content/sample/en, /content/sample/fr and so on. For now, if the assumption is /content/sample/en : level 1, /content/sample/en/pagelevel2 : level 2, /content/sample/en/pagelevel2/pagelevel3 :level3. The count of level 2 and level 3 pages will not be too high for sure, say around 50.

1] What would be the dialog field[ex:pathbrowser,dropdown etc] that can be made use of in this component in the above scenario?

2] Also, what would be the best approach to go about implementing this. Have a drop down and have the servlet get list of pages and show up or some other better way.

Any thoughts/reference code/pointers will be really helpful.

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 leeasling

You can use the second piece of code i posted for the multifield of path fields, this will allow you to select multiple pages at really any level, but you can restrict it by path too.

4 replies

Level 8
February 19, 2017

I may be misunderstanding the requirements, but it would seem you could simply use the OOTB path field and set the root path to the content structure.

<pathField jcr:primaryType="cq:Widget" fieldLabel="Path Field Example" name="./pathField" rootPath="/content/sample/en" xtype="pathfield"/>

If you need to allow them to select multiple then you can put that field inside of a multifield.

<multiPath jcr:primaryType="cq:Widget" fieldLabel="Multi Path" typeHint="String" name="./multiPath" xtype="multifield"> <fieldConfig jcr:primaryType="cq:Widget" fieldLabel="Path Field Example" rootPath="/content/sample/en" allowBlank="{Boolean}false" xtype="pathfield"/> </multiPath>
cquser1
cquser1Author
Level 7
February 19, 2017

Hi leeasling,

Thank you for your reply. Sorry for not being very clear.

If I want to show up pages at level 2[ /content/sample/en/pagelevel2 and  /content/sample/en/pagelevel2sampleone, /content/sample/en/pagelevel2sampletwo and /content/sample/en/pagelevel2samplethree and so on...] OR level 3 [ /content/sample/en/pagelevel2/pagelevel3 and /content/sample/en/pagelevel2/pagelevel3sampleone and /content/sample/en/pagelevel2/pagelevel3sampletwo and /content/sample/en/pagelevel2/pagelevel3samplethree and so on...] in a component, how would I go about doing that, because I should be able to select Level 2 or Level 3 pages from a single dialog field.

leeaslingAccepted solution
Level 8
February 20, 2017

You can use the second piece of code i posted for the multifield of path fields, this will allow you to select multiple pages at really any level, but you can restrict it by path too.

cquser1
cquser1Author
Level 7
February 21, 2017

Hi Leeasling,

Thank you for your reply.

If I give the below [OOTB commerce/components/product ] dialog field in my component dialog in AEM 6.2, it does not show up on the page at all, whereas it works on geometrrix page.

<product

                                jcr:primaryType="nt:unstructured"
                                fieldLabel="Path"
                                name="./productPath"
                                predicate="nosystem"
                                rootPath="/etc/commerce/products"
                                rootTitle="Products"
                                xtype="pathfield"/>

whereas if I give, 

<path
                                jcr:primaryType="nt:unstructured"
                                sling:resourceType="granite/ui/components/foundation/form/pathbrowser"
                                fieldDescription="desc"
                                fieldLabel="label"
                                name="./Path"
                                rootPath="/content/xxx/yyy"/>

it works.

So,am not getting as to where exactly is the problem. 

Any thoughts will be really helpful.