Question

I have this getResourcesCall

[[!getResources? &tpl=GRTpl&includeContent=1&includeTVs=1&parents=[[*id]]]]

In GRTpl I am including [[+content]] tags, but they only display the parent's content, not the content of the children. What gives!?

UPDATE:

I am using ModX output filters in GRTpl. So I have a Single-Select Listbox that displays chunks based on the selection. Here is GRTpl:

[[+tv.section_type:eq=`Type One`:then=`[[$Type One Chunk]]` ]]

[[+tv.section_type:eq=`Type Two`:then=`[[$Type Two Chunk]]` ]]

[[+tv.section_type:eq=`Type Three`:then=`[[$Type Three Chunk]]` ]]

[[+tv.section_type:eq=`Type Four`:then=`[[$Type Four Chunk]]` ]]
Was it helpful?

Solution

So I found the solution. In GRTpl I'm passing a var into each chunk:

[[+tv.section_type:eq=`Type One`:then=`[[$Type One Chunk? &content=`[[+content]]` ]]` ]]

[[+tv.section_type:eq=`Type Two`:then=`[[$Type Two Chunk? &content=`[[+content]]` ]]` ]]

[[+tv.section_type:eq=`Type Three`:then=`[[$Type Three Chunk? &content=`[[+content]]` ]]` ]]

[[+tv.section_type:eq=`Type Four`:then=`[[$Type Four Chunk? &content=`[[+content]]` ]]` ]]`

Then in the chunks [[+content]] displays the child resource's content.

OTHER TIPS

The method used above will result in a lot of extra processing and a slower web site.

Two options:

1) Read Jason Coward's excellent article on Conditionals.

The basic problem is the code shown above will get expanded and processed by MODX even if it does not meet the conditional.

So instead of:

[[*field:is=0:then=[[!SomeScript]]:else=[[$SomeChunk]]]]

Use:

[[[[*field:is=0:then=!SomeScript:else=$SomeChunk]]]]

See http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/ for the details.

2) For further enhancements, replace getResources with pdoResources and use its excellent Conditional Templates which means you do not need to use Conditionals at all.

With pdoResources you can do the following:

[[!pdoResources? &includeTVs=section_type &tplCondition=section_type &conditionalTpls=`{"Type One":"Type One Chunk","Type Two":"Type Two Chunk"} and so on.

Google "modx pdotools" for the docs.

Using this method I sped up what was a TV laden getResources call about 8 times faster.

See http://forums.modx.com/thread/90995/performance-question-with-getresources

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