We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    Say I have:
    [[getResources? 
                    &resources=`1,2,3,4,5,6`
                    &limit=`0`
                    &showHidden=`1`
                    &tpl=`PropItemTPL`
                    &sortby=`menuindex ASC, id`
                    &sortdir=`ASC`
                    &includeContent=`1`
                    &includeTVs=`1`
                    &processTVs=`1`
                    &showUnpublished=`0`
                    ]]


    But resource 2 is actually unpublished.

    In the above format getResources displays it anyway. Is there a way to stop this from happening?

    Thanks
      • 3749
      • 24,544 Posts
      I don't think so. AFAIK, when you use &resources, the other filters are ignored.

      I think you could fix it with a custom snippet that generates the resource list:

      &resources=`[[PubCheck? &docs=`1,2,3,4,5,6`]]


      /* PubCheck snippet */
      
      $docList = $modx->getOption('docs', $scriptProperties);
      $docs = explode(',', $docList);
      $publishedDocs = array();
      
      foreach($docs as $doc) {
         $doc = $modx->getObject('modResource', $doc);
         if ($doc && $doc->get('published')) {
             $publishedDocs[] = $doc;
         }
      }
      
      return implode(',', $publishedDocs);


      I'm not sure what will happen if none of them are published.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting