Question

I was wondering if anyone knew a way to retrieve, say the first 5 (eg: 1 -5) resources of a parent with one getResource line, the retrieve the next 5 (6 - 10) with another getResources line? Kind of like pagination.

I was unable to find something to do this in the documentation.

Was it helpful?

Solution

You want to use the offset and limit properties. Offset is used to skip a specified number of resources returned by the query criteria:

[[!getResources? &parents=`[[*id]]` &tpl=`myRowTpl` &limit=`5`]]

[[!getResources? &parents=`[[*id]]` &tpl=`myRowTpl` &limit=`5` &offset=`5`]]

OTHER TIPS

You might want to look into combining getPage and getResources as this will do the pagination for you...

http://rtfm.modx.com/display/ADDON/getResources#getResources-UsinggetPageforPagination

http://rtfm.modx.com/display/ADDON/getPage

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top