Insert node after concrete sibling node

Avatar

Avatar
Validate 1
Level 2
Anton_Smulskiy
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

4 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 3
View profile

Avatar
Validate 1
Level 2
Anton_Smulskiy
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

4 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 3
View profile
Anton_Smulskiy
Level 2

11-10-2018

Hi,

I have a node structure like:

parsys

- component1

- component2

- component3

- component4

And I need to add 'newComponent' node after 'component2' programmatically.

The result should be:

parsys

- component1

- component2

- newComponent

- component3

- component4

Can't find a way how to add newComponent node to have that order. Can anyone help? Thanks.

Replies

Avatar

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

125 likes

Total Posts

203 posts

Correct reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile
raj_mandalapu
MVP

11-10-2018

First, you need to create a node using node.addNode() then using below code you can change the order

  • Get the recently created node.
  • Get the node and name
  • Use below code

contentNode.orderBefore(dscNode,destNode);

contentNode.save();

Node (Content Repository for Java Technology API Version 2.0)