Search code examples
modx

ModX Revolution getResources tplChunk selection


I have 4 different tplChunks for processing resources fetched by getResources based on user-specified criteria:

        [[!getResources? 
        &parents=`2` 
        &sortby=`id`
        &sortdir=`ASC`
        &tpl=`tplGallery` 
        &tplCondition=`description` 
        &tplOperator=`==` 
        &conditionalTpls=`{"sold":"tplGallery-sold","wide":"tplGallery-W2","soldwide":"tplGallery-W2-sold"}` 
        &includeTVs=`1` 
        &processTVs=`1` 
        &includeContent=`1`
        &limit=`0`]]

Is there a way to do tplChunk selection akin to the way tvFilters does it for resource selection, based on conditions set by user-friendly TVs like checkboxes, as opposed to forcing the user to utilise resource fields?


Solution

  • It's probably easier to use a snippet inside the template you're calling. Inside the chunk you can use a conditional. Since all the placeholders will be loaded already I don't think there would be much of a performance issue.