ModX getResources displays child resources as well as parent level resources

1.5k Views Asked by At

I have getResources call:

[[!getResources? &parents=`[[*id]]` &limit=`15` &tpl=`contentsectiontpl` &sortdir=`ASC` &sortby=`menuindex` &includeContent=`1`]]

In a parent resource.

I wish to only display the child resources of this parent, but the above displays both the child resources, and the resources on the same level as the parent.

Does anyone know the correct way to achieve displaying only the child resources without using the parents ID directly?

4

There are 4 best solutions below

0
On

You could also specify the template, if it's different between parent and child.

Examples:

&where=`{"template:=":8}`

&where=`{"template:=":1, "OR:template:=":2}`

&where=`{"template:IN":[1,2,3]}`
0
On

If youre really getting the parents siblings, you must be specifying the wrong ID. Make sure you shouldnt be using [[+id]] instead of [[*id]], in case youre listing some sort of submenu or such.

0
On

Try '-1' for &parents

Comma-delimited list of ids serving as parents. Use -1 to ignore parents when specifying resources to include. If this is not done, getResources assumes &parents as the current resource and reads it's childs from there (plus the resources given in &resources = unexpected results).

Though it should not be showing the parents sibling resources - I have never seen getResources do this! you are using the call directly in the parent or including it somehow?

If possible you can also hide the parent resource and/or use the hideContainers parameter or possibly the resources parameter to exclude specific [parent] resources.

0
On

Do not make this call in Content field in this parent resource - do it in template. The call is correct, must be something else wrong...