Expand my Community achievements bar.

SOLVED

content node ordering issue.

Avatar

Level 4

@

Hi all,

We have authored a page and the nodes on the crxde getting created based on the sequence of the authoring. Let's say, I have 3 parsys on page par1 , par2 and par3. If I start authoring with par3 - it will be first node that gets created and then if I author par1 and then par2, then the order of nodes appears in page in JCR is jcr:content

|-par3

|-par1

|-par2

We've created a custom JSON response similar to -1.json which produce the JSON structure based on node order and it's being consumed for the mobile website. Now, the problem here is, since the par3 is being authored at start, it appears as first nodes in JSON however, the since the par3 is at the bottom of page in page component so when we see actual page, it appears at the bottom. But, as the mobile site is being generated based on JSON structure, the bottom content of page(desktop website) appears at the top on mobile website. So, is there any way to display the content in mobile site in similar order as it is on desktop website?

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can add your parsys directly in a template or if you have parsys in components , you can add in cq:template node.

Thats will make sure all 3 parsys nodes will be created as soon as page created and will be maintaining the order.



Arun Patidar

View solution in original post

6 Replies

Avatar

Level 10

Never seen a discussion similar to this. I am checking with internal AEM people.

Avatar

Correct answer by
Community Advisor

You can add your parsys directly in a template or if you have parsys in components , you can add in cq:template node.

Thats will make sure all 3 parsys nodes will be created as soon as page created and will be maintaining the order.



Arun Patidar

Avatar

Employee Advisor

I agree with Arun, the easiest work-around is to ensure that the parsys nodes are pre-created when a new page is created by adding the nodes as part of the page template or cq:template if they are included as a component.

Avatar

Level 4

Thanks Arun and Gordon for replying. Approaches you guys suggested will work when we create a new pages . Is there a way to fix this issue for the existing pages ? Regards, Vijay.

Avatar

Community Advisor

You can create a servlet/utility to scan and re arrange nodes.

Not sure if below method would help for nt:unstructured node type Node (Content Repository for Java Technology API Version 2.0)

or you can do with session JCR 1.0: 7.1.7 Moving and Copying (Content Repository for Java Technology API)



Arun Patidar

Avatar

Employee Advisor

I did this experiment:

  • I opened localhost:4502/editor.html/content/we-retail/us/en/experience.html
  • At the bottom I added 3 text components to the responsive grid and added the content "text1", "text2" and "text3" into them.
  • I checked the order of the nodes below /content/we-retail/us/en/experience/jcr:content/root/responsivegrid and found, that the order in the JCR follows the order in the page: first there is the text component containing the text "text1", then the component for "text2" and finally the component for "text3".
  • Then I changed the order of the components in the page by dragging the text3 component directly below the text1 component, so on the page the order is now "page1", "page3", "page3".
  • I validated in the CRXDE that the ordering of the nodes in the JCR has changed as well.

This means, that in a parsys (or a responsive grid) the order of the components in the JCR and the order in the page are always identical. No matter in what order you created them. Just the order matters. And when you iterate through the child nodes of that "responsivegrid" node using your own code, you will get exactly this order!

Outside of the parsys or responsive grid the situation is different. Here the order typically does not matter, also because an author cannot just drag components into the page, but you as developer / template editor have to add them explicitly. And of course then order is not defined. But your (page) components should know how to deal with that situation, and you should add that logic to your custom JSON exporter too.

(And by the way: If you use the Sling Model Exporter, you can eliminate quite a bit of code ...)

HTH,

Jörg