내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

CRX Package Import Order

Avatar

이전 커뮤니티 멤버

Hello,

AEM 6.1.

 

We are mass migrating content into AEM via CRX Package. The nodes are created correctly but they appear in the CRX not in a alphabetically order.

Is there a way to order the nodes in a alphabetically order by using a script after the import or setting a specific attribut in the .conten.xml before the import?  

P.ex:

    - Folder

        -node b

        -node c

        -node a

change order to:

    -Folder

       -node a

       -node b

       -node c

 

 

Kind regards,

 

Jerry

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
이전 커뮤니티 멤버

the folder has the type cq:page . 

 

It seems to be a problem with order of adding content to the package before importing.

 

For anybody interested in a workaround to sort the children alphabetically in CRX  with Linux (no guarantee):

USER=admin PASS=<pass> URL="http://localhost:4502" DIRECTORY=<directory for which the children should appear in a sorted order> echo $DIRECTORY | grep -Po '[^/a-zA-Z0-9-_]' if [ $? -eq 0 ]; then echo " $DIRECTORY - does not seem to be a correct directory" fi HTTP_STATUS_CODE=`curl -s -I -u $USER:$PASS $URL$DIRECTORY.1.json | grep -P "HTTP(.*) 200 OK" | wc -l` if [ $HTTP_STATUS_CODE -ne 1 ]; then echo "- $URL$DIRECTORY does not exist. Exiting" exit 1 fi children=`curl -s -u $USER:$PASS $URL$DIRECTORY.1.json | grep -Po '"[^"]*":{' | grep -Po '[^"](.*)[^":{]'` if [ $? -ne 0 ]; then echo "- Problem parsing children. Exiting" exit 1 fi sorted_children=`for i in $children do if [ $i != "jcr:content" ]; then echo $i fi done | sort` count=1 echo "  - New sort order:" for i in $sorted_children do curl -s -u $USER:$PASS -F":order=$count"  $URL$DIRECTORY/$i  > /dev/null echo "    - $i " if [ $? -ne 0 ]; then echo "- Problem ordering children. Exiting" exit 1 fi count=$((count+1)) done

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Level 10

WHen packages are installed - the nodes are not ordered (for example /content/dam). They appear the same way as they were when the package was created. 

TO order them - you would have to write custom logic using the JCR API. You can use a method such as: 

http://www.day.com/maven/jcr/1.0/7.1.7_Moving_and_Copying.html

However - from a performance perspective - there is no benefit in ordering the nodes.  

Avatar

Level 2

If Folder node primaryType  is  nt:Folder or sling:Folder , the child nodes should be alphabetically sorted.

If folder type is sling:OrderedFolder, the results might contain nodes ordered the way it were put into repository by a package or code.

Avatar

정확한 답변 작성자:
이전 커뮤니티 멤버

the folder has the type cq:page . 

 

It seems to be a problem with order of adding content to the package before importing.

 

For anybody interested in a workaround to sort the children alphabetically in CRX  with Linux (no guarantee):

USER=admin PASS=<pass> URL="http://localhost:4502" DIRECTORY=<directory for which the children should appear in a sorted order> echo $DIRECTORY | grep -Po '[^/a-zA-Z0-9-_]' if [ $? -eq 0 ]; then echo " $DIRECTORY - does not seem to be a correct directory" fi HTTP_STATUS_CODE=`curl -s -I -u $USER:$PASS $URL$DIRECTORY.1.json | grep -P "HTTP(.*) 200 OK" | wc -l` if [ $HTTP_STATUS_CODE -ne 1 ]; then echo "- $URL$DIRECTORY does not exist. Exiting" exit 1 fi children=`curl -s -u $USER:$PASS $URL$DIRECTORY.1.json | grep -Po '"[^"]*":{' | grep -Po '[^"](.*)[^":{]'` if [ $? -ne 0 ]; then echo "- Problem parsing children. Exiting" exit 1 fi sorted_children=`for i in $children do if [ $i != "jcr:content" ]; then echo $i fi done | sort` count=1 echo "  - New sort order:" for i in $sorted_children do curl -s -u $USER:$PASS -F":order=$count"  $URL$DIRECTORY/$i  > /dev/null echo "    - $i " if [ $? -ne 0 ]; then echo "- Problem ordering children. Exiting" exit 1 fi count=$((count+1)) done