We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46073
    • 65 Posts
    I have a getResources pulling in an image and title from a bunch of product pages to be included in a homepage gallery. The product pages use MIGx to input the image and title. The getResources works great as is, but some product pages don't have images which is causing blanks in my gallery, what's the best way to exclude getResources from pulling in the resources without images?

    thanks as usual!
      • 4172
      • 5,888 Posts
      snippet code of getMigxGalleryIds:

      $tv_id = $modx->getOption('tv_id',$scriptProperties,0);
      
      $classname = 'modTemplateVarResource';
      $c = $modx->newQuery($classname);
      $c->where(array('value:!='=>'[]'));
      $c->where(array('value:!='=>''));
      $c->where(array('tmplvarid'=>$tv_id));
      
      $ids = array();
      $ids[] = 0;
      if ($collection = $modx->getCollection($classname,$c)){
          foreach ($collection as $object){
              $ids[] = $object->get('contentid');
          }
      }
      return $modx->toJson($ids);
      



      this should give you a list with all Resources, which have MIGX-items:

      [[getMigxGalleryIds?&tv_id=`12`]]
      


      change the tv_id to the id of your MIGX-TV and use it together with getResources like that:

      [[getResources?
      &parents=`0`
      &limit=`0`
      &tpl=`@INLINE [[+pagetitle]]([[+id]])<br >`
      &where=`{"id:IN":[[getMigxGalleryIds?&tv_id=`12`]]}`
      ]]
      
      [ed. note: Bruno17 last edited this post 12 years, 8 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!