We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I'm trying to create a menu which excludes the children of specific container resources.

    The Wayfinder docs (https://rtfm.modx.com/extras/evo/wayfinder#Wayfinder-GeneralParameters) show a parameter for filtering:
    &where : JSON style filtering option. For example when trying to hide blog or news from the Articles addon: &where=`[{"class_key:!=": "Article"}]`

    I have tried various options to use this parameter to filter out the children of specific parent (container) resources, and simpler tests, eg
    &where=`[{"parent:NOT IN": array(5,61)}]` - doesn't work: child resources show
    &where=`[{"parent:NOT IN": "array(5,61)"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent:NOT IN": array("5","61")}]` - doesn't work: child resources show
    &where=`[{"parent:NOT IN": "5,61"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent:NOT IN": "(5,61)"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent:NOT IN": (5,61)}]` - doesn't work: child resources show
    &where=`[{"parent:=": 5}]` - breaks Wayfinder: no menu at all
    &where=`[{"parentId:=": "5"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parentid:=": "5"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent_id:=": "5"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent": "5"}]` - breaks Wayfinder: no menu at all
    &where=`[{"parent:NOT IN" => array(5,61)}]` - doesn't work: child resources show
    &where=`[{"parent:!=' => 5}]` - doesn't work: child resources show
    but so far can't get this to work.

    Can anyone tell me how to do this?

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 37377
      • 64 Posts
      How about this?
       &where=`[{"parent:NOT IN": [1,3]}]`
      • discuss.answer
        • 10525
        • 247 Posts
        Steffan, if there was a cuddly toy, you would have won it!

        Thanks and well done. This works perfectly for me.

        Is this a normal syntax for arrays that I've missed? The &where param supposedly uses the syntax for xPDO WHERE clauses (https://rtfm.modx.com/xpdo/2.x/class-reference/xpdoquery/xpdoquery.where), although I don't see much resemblance.
        • I think that's a JSON construct for arrays.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 37377
            • 64 Posts
            Glad I could be of assistance smiley

            The syntax is indeed JSON for 1 dimensional arrays