0

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?

MeltingDog
  • 14,310
  • 43
  • 165
  • 295

2 Answers2

0

You can add "where" clause as one of your parameters, narrowing result set to only published documents:

[[getResources?
                &parents=`4`
                &resources=`' . $ids . '`
                &limit=`0`
                &showHidden=`1`
                &tpl=`PropItemTPL`
                &sortby=`menuindex ASC, id`
                &sortdir=`ASC`
                &includeContent=`1`
                &includeTVs=`1`
                &processTVs=`1`
                &where=`{"published" : true}`
           ]]
jacek_podwysocki
  • 807
  • 10
  • 30
0

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.

David Pede
  • 68
  • 1
  • 9