We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20215
    • 144 Posts
    How to filter by template, avoiding using a foreach later?

    $parentIDs = $modx->getParentIds($resID, 2, array('context' => 'web', 'published' => true, 'template' => 2)); //doesn't work

    This question has been answered by Bruno17. See the first response.

      ----------------------------------
      canale irc Italiano #modx server: tophost.azzurra.org
    • discuss.answer
      • 4172
      • 5,888 Posts
      As far, as I can tell, 'context' is the only key, which you can send with the options-array.
      But you can put the result into a new query for addional filtering.

      $parentIDs = $modx->getParentIds($resID, 2, array('context' => 'web'));
      $ids = array();
      if ($collection = $modx->getCollection('modResource',array('id:IN'=>$parentIDs,'template'=>2,'published'=>1))){
          foreach ($collection as $object){
              $ids[] = $object->get('id');
          }
      }




        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 20215
        • 144 Posts
        As I suspected. it's a shame..

        thank you Bruno
          ----------------------------------
          canale irc Italiano #modx server: tophost.azzurra.org