Siblings | Community
Skip to main content
Level 3
October 16, 2015
Solved

Siblings

  • October 16, 2015
  • 7 replies
  • 4014 views

How to get siblings? For example somethig like node.getNextSibling() or node.getPreviousSiblings()? I cannot find in API

Why I need it. After the live copy creation the node order is wrong in the live copy. I mean the node order is different in the live copy and in the blueprint. There is an orderChildren sync action in the default rollout configuration. But... Unfortunately orderChildren does not help

Thanks

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 smacdonald2008

The JCR API does not support getSibiling(). That would be a good method for the API to have included.

A workaround is to write a custom algorithm that calls  getParent() and then get all the children of that parent. Then you can figure out the nodes under that parent thereby determining the siblings. 

A
 ....B
.....C
.....D

Therefore if you wanted to find out the siblings of Node C - you can call getParent() and then that will return Node A. Then you can call     getNodes() which will return Nodes B,C, and D. That is the only way that you can find out which siblings Node C has.  

HTH

7 replies

Sham_HC
Level 10
October 16, 2015

W.r.t live copy requirement it should maintain order. Which version of CQ & are you losings order within child page of live copy.

smacdonald2008
Level 10
October 16, 2015
StanleyorAuthor
Level 3
October 16, 2015

smacdonald2008 wrote...

Did you read this document: http://www.day.com/specs/jcr/2.0/22_Same-Name_Siblings.html ? 

 


Yes, I saw this document. Although my question is not related with SNS because there are no siblings with the same name.

For example there are nodes:
- A

- B

- C

How to get the position of B? That the next sibling of B is C and the previous sibling is A

StanleyorAuthor
Level 3
October 16, 2015

Sham HC wrote...

W.r.t live copy requirement it should maintain order. Which version of CQ & are you losings order within child page of live copy.

 


It maintains the order, for example, for geometrix. In my case I have a site with 4000 pages and after live copy creation, the order of the pages in the live copy is wrong.
 
I use 5.5 and the package cq-update-pkg-5.5.10.zip is installed.
 
That is correct, the order within child pages of the live copy is different comparing to the blueprint.

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

The JCR API does not support getSibiling(). That would be a good method for the API to have included.

A workaround is to write a custom algorithm that calls  getParent() and then get all the children of that parent. Then you can figure out the nodes under that parent thereby determining the siblings. 

A
 ....B
.....C
.....D

Therefore if you wanted to find out the siblings of Node C - you can call getParent() and then that will return Node A. Then you can call     getNodes() which will return Nodes B,C, and D. That is the only way that you can find out which siblings Node C has.  

HTH

Sham_HC
Level 10
October 16, 2015

You need to install sp3 + hotfix  to get correct order of child pages in live copy.  Please file daycare & will help you further to resolve it.

StanleyorAuthor
Level 3
October 16, 2015

smacdonald2008 wrote...

The JCR API does not support getSibiling(). That would be a good method for the API to have included.

A workaround is to write a custom algorithm that calls  getParent() and then get all the children of that parent. Then you can figure out the nodes under that parent thereby determining the siblings. 

A
 ....B
.....C
.....D

Therefore if you wanted to find out the siblings of Node C - you can call getParent() and then that will return Node A. Then you can call     getNodes() which will return Nodes B,C, and D. That is the only way that you can find out which siblings Node C has.  

HTH

 

 


I thought about the same solution but still hoped that there is a right way, not workaround. Thank you