We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21017
    • 3 Posts
    Hello,

    I am creating a snippet which list Resource IDs dynamically.
    I have a string variable $parentIDs which contains comma delimited IDs but I can’t use this variable in the query. With the commented line the script works great. It is possible to use variable for parent in this query? thanks.

    $d = $modx->newQuery('modResource');
    $d->where(array(
      'template' => 5,
      //'parent:IN' => array(23,22,21,24,25,9)
      'parent:IN' => array($parentIDs)
    ));
    $prod = $modx->getCollection('modResource',$d);
      • 28215
      • 4,149 Posts
      $d = $modx->newQuery('modResource');
      $d->where(array(
        'template' => 5,
        'parent:IN' => explode(',',$parentIDs),
      ));
      $prod = $modx->getCollection('modResource',$d);
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 21017
        • 3 Posts
        it works thank you. smiley