We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    I have a normal MIGX TV + MIGX config, where one field is defined as a listbox-multiple fieldtype/tv. With this I give the option to categorize the migx items with one or more categories. The problem I'm facing is how to filter the items in the frontend with the where property of the getImageList snippet which I'm using regularly but never with this fieldtype.

    Let's say I have an a few items with assigned categories "category1" and "category2", and a few with only "category2", how would I now filter only items with "category2"?

    I tried this:

    [[getImageList? &tvname=`migxtv` &docid=`44` &tpl=`itemTpl` &limit=`0` &where=`{"category":"category2"}`]]
    
    // or
    
    [[getImageList? &tvname=`migxtv` &docid=`44` &tpl=`itemTpl` &limit=`0` &where=`{"category:LIKE":"%category2%"}`]]
    


    which only outputs the items that just have a single category "category2" assigned, but not the ones with also another category. In the JSON DB-Record I see single category items saved as "category":"category2" while multi category items have an array as value like "category":["category1", "category2"], which is likely the problem here...but I have no idea how to solve this^^...any hints on how to do this?

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40045
        • 534 Posts
        Thank you Bruno! Brought me on the right track, wasn't aware of these custom filters (just tried the standard xPDO query ones), I now use

        &where=`{"category:find_in_set":"category1"}`
        


        but I had to modify the migx class btw. the find_in_set filter (sent a PR https://github.com/Bruno17/MIGX/pull/149) slightly, as it was trying to explode the input/subject array which resulted in null instead of checking the already passed array.