Search code examples
modxmodx-revolutionmodx-getresources

Way to have getResources not show unpublished IDs if given a list of IDs


I've got an SQL query that spits out a group of IDs. I feed these IDs to a getResources call as such:

         [[getResources?
                &parents=`4`
                &resources=`' . $ids . '`
                &limit=`0`
                &showHidden=`1`
                &tpl=`PropItemTPL`
                &sortby=`menuindex ASC, id`
                &sortdir=`ASC`
                &includeContent=`1`
                &includeTVs=`1`
                &processTVs=`1`
                &showUnpublished=`0`
           ]]

Problem is this shows all IDs, even if they're unpublished.

I've included &showUnpublished='0' but this makes no difference.

Would anyone know if there's a way to have this work with getResources? Or do I need to re-write my PHP and MySQL?


Solution

  • The resources parameter is separate from the rest of the selection logic. If you include a resource's id in the resources property, it will be included regardless of any other selection properties.

    Try pdoResources and I don't think you'll have this problem. It's also much quicker than getResources.