symlink
symlink

Reputation: 12218

getResources displays all subdirectories

In modx I have a resource that goes two folders deep. I'm trying to only display the resources in the parent directory (not the resources in its subdirectories). My getResources call is in the parent resource and reads:

[[!getResources? 
    &parents=`[[*id]]` 
    &showHidden=`1` 
    &includeContent=`1` 
    &includeTVs=`1` 
    &processTVs=`1` 
    &tvPrefix=`` 
    &limit=`0` 
    &tpl=`Attractions Section` 
    &sortby=`menuindex` 
    &depth=`1`
]]

As far as I understand it, the depth parameter should control how deep gr goes to display its resources. I've set depth to 0 and 1, and it's still displaying all the resources in the subdirectories. How do I get it to only display the current directory's resources?

Upvotes: 0

Views: 1708

Answers (2)

symlink
symlink

Reputation: 12218

Got it. depth=`depth` returns first level of resources below parent ModX Docs.

Upvotes: 0

Sean Kimball
Sean Kimball

Reputation: 4494

I've had problems with getResources before and the ~order~ of things ~if~ one of your other attrib values is incorrect, it may be ignoring subsequent attributes. so to start get rid of any that you are not using or do not actually need [tvprefix, sortby is menuindex by default I think] then move depth right up to under parents.

Also I've always treated modx chunk, snippet, TV & template names as variables, i.e. 'no spaces or weird characters' I really don't know if it matters or not, but your tpl name looks suspicious.

But yes, you are right &depth=0 should only be selecting the first level of resources.

Upvotes: 1

Related Questions