Skip to main content
vikramca06
Level 4
May 16, 2017
Solved

How to move a node to a particular position programmatically?

Hi All,

I want to move a node above or below to a particular node in sightly handler. Similar to how we order a node in CRXDE manually. 

Ex:

jcr:Content

    Node1

    Node2

    Node0

Now, I want to move Node0 above Node1, in sightly handler.

Regards,

Vikram.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Nupur_Jain
Nupur_JainAccepted solution
Adobe Employee
May 16, 2017

Hi Vikram,

There is  com.day.cq.commons.jcr.JcrUtil API available through which you can reorder/move your nodes.There is setChildNodeOrder() method where you specify the new order for the children.

 

Hope this helps!

Nupur

2 replies

Nupur_Jain
Adobe Employee
Nupur_JainAdobe EmployeeAccepted solution
Adobe Employee
May 16, 2017

Hi Vikram,

There is  com.day.cq.commons.jcr.JcrUtil API available through which you can reorder/move your nodes.There is setChildNodeOrder() method where you specify the new order for the children.

 

Hope this helps!

Nupur

Translate
Level 2
January 13, 2023

 

Session session = resourceResolver.adaptTo(Session.class);

session.move(srcpath,destpath);

session.save();

 

Translate