Expand my Community achievements bar.

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

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

CRX Package Import Order

Avatar

Former Community Member

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 Accepted Solution

Avatar

Correct answer by
Former Community Member

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

View solution in original post

3 Replies

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

Correct answer by
Former Community Member

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