We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5160
    • 118 Posts
    Looks like I need to be hanging my head in shame... turns out this was a typo hangover from the first version of the snippet that I wrote. When building the $where variable line 3 in the second code block of my first post reads:
    $where .= '&where={';

    It should read:
    $where .= '{'


    So the full, working snippet is below:
    <?php
    
    if (isset($_POST['btn_submit']) && $_POST['btn_submit'] == 'submit') {
    
      $where .= '{';
    
      if(!empty($_POST['filter_name_last'])) {
    	$where .= '"pers_name_last:LIKE":"'.$_POST['filter_name_last'].'%",';
      }
      if(!empty($_POST['filter_pro_establishment_main'])) {
    	$where .= '"pro_establishment_main":"'.$_POST['filter_pro_establishment_main'].'",';
      }
      if(!empty($_POST['filter_quali_grade'])) {
    	$where .= '"quali_grade":"'.$_POST['filter_quali_grade'].'",';
      }
    
      // remove last comma from $where string as it breaks the snippet call
      $where = rtrim($where, ',');
    
      $where .= '}';
    
    }
     
    $params['where'] = $where;
    $params['element'] = 'Rowboat';
    $params['table'] = 'my_table';
    $params['sortBy'] = 'my_field';
    $params['totalVar'] = 'rowboat.total';
    $params['tpl'] = 'my_template';
    $params['cache'] = '0';
    $params['cacheResults'] = '0';
    $params['limit'] = '10';
    
    return $modx->runSnippet('getPage', $params);


    Thanks to all who responded.