<![CDATA[ MIGX 'where' filter, 'snippet', 'contains' - MODX Community Forums]]> https://forums.modx.com/thread/?thread=88890 <![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039?page=2#dis-post-560532 I have string that is calling page ID and a &where filter to pull agriculture related PDFs for various crops. Some crops would need the same pdf file.

[[getImageList? &tvname=`resources` &tpl=`resourceTpl` &tplFirst=`FresourceTpl` &docid=`3` &sort=`[{"sortby":"type","sortdir":"DESC"},{"sortby":"title","sortdir":"ASC"}]` &where=`{"crop:=":"[[*id]]"}` ]]



This works great when there is only one value in the string but in cases where there is multiple it fails.
I have tried:

  • contains
  • in
  • find_pd

Citrus==13||Stone Fruit==14||Almond==77||Pecan==15||Young Perennial==12||Standard Veggies==17||Bell Pepers==18||Onions==19||Lettuce==20||Squash/Cucurbit==21 ....

There is 20+ in the string.

The problems is when multiples of those are connected to the same item.

Here is the value in the DB
[{"MIGX_id":"1","type":"Product Label","title":"CYAN 365 Product Label","description":"CYAN 365 Product Label","file":"cyan360product-label.pdf","crop":["77","13","15","14","12"],"product":"6"},{"MIGX_id":"2","type":"Product Label","title":"Vegro Blueberry Label","description":"VEGRO Blueberry Product Label","file":"vegro-blueberry-product-label.pdf","crop":"24","product":"72"},{"MIGX_id":"3","type":"Product Label","title":"VEGRO STD Label","description":"VEGRO Standard Product Label","file":"vegroSTD-product-label.pdf","crop":["18","20","19","26","21","17","23","28","27"],"product":"7"},{"MIGX_id":"4","type":"Product Label","title":"PHYSIOPOWER Product Label","description":"PHYSIOPOWER Product Label","file":"physiopower-product-label.pdf","crop":"29","product":"8"},{"MIGX_id":"5","type":"Safety Datasheets","title":"","description":"CYAN 365 Product Safety Datasheet","file":"cyan365-safetysheet.pdf","crop":["77","13","15","14","12"],"product":"6"},{"MIGX_id":"6","type":"Safety Datasheets","title":"","description":"VEGRO Product Safety Datasheet","file":"vegro-safetysheet.pdf","crop":["18","20","19","26","21","17","23","28","27"],"product":"7"},{"MIGX_id":"7","type":"Safety Datasheets","title":"","description":"PHYSIOPOWER Product Safety Datasheet","file":"physiopower-safetysheet.pdf","crop":"29","product":"8"},{"MIGX_id":"8","type":"Product Label","title":"BIOSTIM 777 Product Label","description":"BIOSTIM 777 Product Label","file":"","crop":"24","product":"72"},{"MIGX_id":"9","type":"Product Label","title":"UNIFLO™ Product Label","description":"UNIFLO™ Product Label","file":"","crop":"25","product":"73"}]


Offering Beer for HELP....

Thanks
]]>
Exceleron Aug 08, 2018, 04:18 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039?page=2#dis-post-560532
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531992 Otherwise you would have duplicate array-keys, where only one would make it into the array.

Another way would be, to make sure the values start and ends allways with a double-pipe in the db.
Also adding the doublepipes with the query would be possible.
I'm sure, I had posted examples for both solutions at the forums.]]>
Bruno17 Sep 22, 2015, 04:48 AM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531992
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531987 'where'=>'[{"kategorien":"'.$category.'"},{"OR:kategorien:LIKE":"%||'.$category.'||%"},{"OR:kategorien:LIKE":"%'.$category.'||%"},{"OR:kategorien:LIKE":"%||'.$category.'%"}]']]> sonicpunk Sep 22, 2015, 03:48 AM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531987 <![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531943 'where'=>'{"kategorien:IN":"'.$category.'"}'
or
'where'=>'{"kategorien:find_pd":"'.$category.'"}'

and am having no luck.

The database column is called "kategorien" and I am via a GET request getting the category value.

What is the proper syntax here to look through a pipe delimited string?
]]>
sonicpunk Sep 21, 2015, 02:38 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-531943
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-489044
Anyway, thanks indeed for your help, and the timely fashion in which it was given.

PS: The migx documentation is rather out of date, or at least inexhaustive. None of the filter stuff is documented from what I can see.]]>
davidsmith Feb 03, 2014, 11:04 AM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-489044
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488858
snippet 'filter_inarray':

$operand = $modx->getOption('operand',$scriptProperties,'');
$subject = $modx->getOption('subject',$scriptProperties,'');

if (is_array($subject)){
    return  in_array($operand,$subject) ? '1' : '';
}

return $operand == $subject ? '1' : '';


[[!getImageList? 
&tvname=`images` 
&where=`{"days:snippet:filter_inarray":"Freitag"}`]]


the result:

http://www.revo222.webcmsolutions.de/75/days.html



]]>
Bruno17 Jan 31, 2014, 03:44 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488858
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488853
{"MIGX_id":"5","title":"Early bird menu","status":"Enabled","days":["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}

I was only seeing the flattened output after modx had essentially squirted the array onto the screen. So it's not pipe delimited - it's actually an array it seems [Edit: unless migx is just rendering it like this even though it's really pipe delimited. But in either case, neither 'find_pd' nor 'in' have worked].

But I tried using 'in' instead of 'contains' or 'find_pd' and it didn't find what I was looking for.]]>
davidsmith Jan 31, 2014, 03:10 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488853
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488852 if I'm not wrong.

But let me see your unprocessed output of your MIGX-TV.
You can get it by putting the TV-tag of your MIGX-TV into the content:

[[*yourMIGXtv]]
]]>
Bruno17 Jan 31, 2014, 03:04 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488852
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488851
In case I've misunderstood I'll certainly give it a shot. Thanks for the github link - I see the list of possibilities. I also see that 'contains' is essentially using strpos to look for the input string. Unless I've wrong, it looks like the following code isn't actually producing the expected result:

case 'contains':
  $output = strpos($subject, $operand) !== false ? $then : (isset($else) ? $else : '');
  break;


Where $subject = 'MondayTuesdayWednesdayThursdayFridaySaturday'
$operand = 'Sunday'
$then = 1
$else = false

Why might that return 1? my concern about find_pd is that the subject isn't pipe delimited. Are you suggest that I arrange for the output of that TV to be delimited? Or perhaps is there a way I have yet to discover to pipe delimit the output of my compound checkbox TV content using a standard output filter?]]>
davidsmith Jan 31, 2014, 02:48 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488851
<![CDATA[Re: MIGX 'where' filter, 'snippet', 'contains']]> https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488848
&where=`{"days:find_pd":"Sunday"}


https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1592]]>
Bruno17 Jan 31, 2014, 02:25 PM https://forums.modx.com/thread/88890/migx-039-where-039-filter-039-snippet-039-039-contains-039#dis-post-488848