getResources can sort by menuindex - which is great for items in one folder/container. However, I need to sort the children of several folders in one overall order, i.e:
Folder 1
- item 1
- item 2
Folder 2
- item 3
- item 4
Folder 3
- item 5
- item 6
To display: item 1, item 2, item 3, etc.
Because the menuindex value is defined by a resource’s position in its parent container, the getResources &sortby=`menuindex` does not work for multiple folders. You end up with loads of resources with the same menuindex value, so the sort order is more or less random. Sorting by `publishedon` works because this is not defined by the container. Trouble is, I don’t want to sort in publishedon order - I need to sort in the order the resources appear in the resource tree.
So my question is:
is there a way to sort child resources of multiple folders based on their position in the resource tree
For reference, my current code is:
[[getResources? &parents=`[[*parent]]` &depth=`2` &resources=`-[[*id]]` &limit=`` &hideContainers=`1` &includeTVs=`1` &sortby=`menuindex` &sortdir=`ASC` &tpl=`product_list` ]]
[ADDENDUM]
One obvious way round this issue is to manually change all the menuindex values so they run sequentially down the resource tree, but then I would have to amend this every time a new child resource was created or moved.
Another option would be to create a snippet that first sorts on the parent’s menuindex and then on the child’s - but I don’t really know how to go about doing this. Any takers?