Sort pages for specific folders in aem sites.html | Community
Skip to main content
February 7, 2025
Solved

Sort pages for specific folders in aem sites.html

  • February 7, 2025
  • 2 replies
  • 614 views

we need to sort pages alphabetically on for specific folders. I tried to overlay the OOTB path /libs/wcm/core/content/sites/jcr:content/views/column/datasource to /apps but it doesnt seem to work because the sling:resoureType of libs folder path is cq/gui/components/common/wcm/datasources/childpages and i couldnt find this path in my aem. 

 

I tried to add jsp code  here : /apps/cq/gui/components/coral/admin/page/columnitem/columnitem.jsp. we have used this jsp to manipulate the page names and title. But for this requirement this also doesnt seem to work. 

 

can someone help me with this ? 

Best answer by ManviSharma

Hi Sushma,

Sorting pages alphabetically in AEM, particularly for specific folders, involves understanding and potentially extending the functionality of the existing datasource and views. Based on your problem statement, there are a few key points and approaches you can consider:

Key Observations and Challenges:
-----------------------------------------------------

i) cq/gui/components/common/wcm/datasources/childpages:

The sling:resourceType you mentioned points to an out-of-the-box (OOTB) datasource used for fetching child pages. If you cannot locate this path, it could be because the Sling model or the datasource is either not extended or not exposed directly in your instance. It might also be included in a bundle or service rather than as a visible node in CRX.

ii) JSP Customization (/apps/cq/gui/components/coral/admin/page/columnitem/columnitem.jsp):

While you can manipulate titles and page names with this JSP, it does not directly control the sorting of pages in the datasource. Sorting needs to happen at the datasource or query level, not in the rendering layer.


--> Customize the Datasource

  • To implement alphabetical sorting, you need to overlay the OOTB datasource or create a custom datasource.
  • Steps:
    1. Identify the childpages datasource implementation.
    2. Overlay it to /apps/cq/gui/components/common/wcm/datasources/childpages.
    3. Modify the query or logic to include sorting by jcr:title or jcr:name in ascending order.
    4. Example Query:
      query.setSortOrder("jcr:title", QueryBuilder.DESCENDING);
    5. Register the updated datasource in your dialog or view configuration.



Regards,
Manvi Sharma

2 replies

Shashi_Mulugu
Community Advisor
Community Advisor
February 8, 2025

Hi @sushmana1 you can try overlaying /libs/granite/ui/components/coral/foundation/columnview

 

Here you can get OOTB datasource, iterate and sort 

 

Here you can write Condition if currentresource.getpath() is your Condition folder or not

ManviSharma
Adobe Employee
ManviSharmaAdobe EmployeeAccepted solution
Adobe Employee
February 9, 2025

Hi Sushma,

Sorting pages alphabetically in AEM, particularly for specific folders, involves understanding and potentially extending the functionality of the existing datasource and views. Based on your problem statement, there are a few key points and approaches you can consider:

Key Observations and Challenges:
-----------------------------------------------------

i) cq/gui/components/common/wcm/datasources/childpages:

The sling:resourceType you mentioned points to an out-of-the-box (OOTB) datasource used for fetching child pages. If you cannot locate this path, it could be because the Sling model or the datasource is either not extended or not exposed directly in your instance. It might also be included in a bundle or service rather than as a visible node in CRX.

ii) JSP Customization (/apps/cq/gui/components/coral/admin/page/columnitem/columnitem.jsp):

While you can manipulate titles and page names with this JSP, it does not directly control the sorting of pages in the datasource. Sorting needs to happen at the datasource or query level, not in the rendering layer.


--> Customize the Datasource

  • To implement alphabetical sorting, you need to overlay the OOTB datasource or create a custom datasource.
  • Steps:
    1. Identify the childpages datasource implementation.
    2. Overlay it to /apps/cq/gui/components/common/wcm/datasources/childpages.
    3. Modify the query or logic to include sorting by jcr:title or jcr:name in ascending order.
    4. Example Query:
      query.setSortOrder("jcr:title", QueryBuilder.DESCENDING);
    5. Register the updated datasource in your dialog or view configuration.



Regards,
Manvi Sharma