0
$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.

curveball
  • 4,320
  • 15
  • 39
  • 49

2 Answers2

0

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.

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
0

Where needs to be formatted as a JSON value, so you would need to define which field you are querying against and format as JSON. E.g. 'where' => $modx->toJSON(array('pagetitle'=>$_GET['search']))

matdave
  • 21
  • 2