Search code examples
searchfiltermodxmodx-revolutionmigx

ModX Revo getimagelist snippet. How can I search for a string in the field?


$output = $modx->runSnippet('getImageList',array(
   'tvname' => 'workOrders',
    'where' => $_GET['search'] ,
   'tpl' => 'workOrdersList',
   'docid' => 3
));

One of the fields is a string with parameters. How can I check whether my search string is a part of that field? I have looked up how to use "where" parameter to accomplish this task but I am still stuck.


Solution

  • If you just use this extra (getUrlParam), you can call this instead of refering to the GET directly:

    So your call could look like this:

    $output = $modx->runSnippet('getImageList', array(
        'tvname' => 'workOrders',
        'where' => $modx->runSnippet('getUrlParam', array('name' => 'search`)),
        'tpl' => 'workOrdersList',
        'docid' => 3
    ));
    

    This also takes care of malicious url parameters.