Fetch contents according to its order


I have a quick question regarding sorting contents in the admin console.

I know that “”_manualordervalue DESC"" will fetch all contents according to its order, however in order for this to work you have to set “Manually Sorted” to be on in Sort Items menu.

I would like to fetch the contents according to its positions regardless what options is selected in Sort items menu.

Is there a way for achieving this?

thx in advance.

Enonic version: 6.4.1
OS: Ubuntu 15.10

Hi Oliver,

If you use getChildren or query with a path you can use the parameters start and count (a bit unsure on exact paeam names, check the docs, im on mobile right now). Set start to 2 and count to 1 to get second item only.

You could also always get all content and that pick one with result.hits[4]

No manual sort needed for this to work.


If you use content.query http://repo.enonic.com/public/com/enonic/xp/docs/6.4.1/docs-6.4.1-libdoc.zip!/module-lib_xp_content.html#.query

There is a sort parameter that will be applied regardless of specified order values.
The ordering in content studio will only apply when you are using content.getChildren I assume?

I think the default behavior in the Content Studio is to show the most recently modified content on top.

In both contentLib.getChildren and contentLib.query you can use sort: '_modifiedTime ASC' which will put the newest on top. Or if that doesn’t match, try 'DESC'. But I’m afraid that using the “sort” parameter will override the manually sorted items. There should be a way to check if a content’s children are manually sorted.


Maybe I wasn’t clear enough on what I meant.

I would like to fetch the items in this exactly order that appears in the picture above (Finn riktig prove, Send inn prove, Prislister…) no matter what option is select in Sort items (could be “Manually Sorted”, “Modified - Ascending”, “DisplayName - Ascending”, …).

“_manualordervalue DESC” will accomplish that, however I need to set “Manually Sorted” otherwise it won’t work. If I change to any other option such as “DisplayName - Desceding” or “DisplayName - Ascending” then the “_manualordervalue DESC” will no longer work.

Do you guys know what I mean? :grin:

1 Like

Ah… Just use content.getChildren without specifying any sort order :slight_smile:

It works now.
Thank you for that tsi.

1 Like