We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24531
    • 213 Posts
    Hey there!

    i’m using my own custom snippet to dynamically filter the collection got by getResources. e.g User can filter out resources by date interval (from publishedon to publishedon) AND keyword contained in pagetitle or content. Then i generate JSON and put it to &where parameter and here comes my question.
    my where param looks like this:
    {"publishedon:>=":"1289865600", "AND:publishedon:<=":"1291075200", "AND:pagetitle:LIKE":"%test%", "OR:content:LIKE":"%test%"}
    

    which is obviously producing wrong results, the correct query should look like:
    "publishedon:>=":"1289865600", "AND:publishedon:<=":"1291075200" and ("pagetitle:LIKE":"%test%", "OR:content:LIKE":"%test%")
    


    What are my routes to solve this problem?

    Thanks


    btw, i checked source code and there’s following comment: &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}` <-- this would not work, json_decode won’t parse that
      • 10638
      • 57 Posts
      hi rav3n did you end up solving this? I ran into the same issue.
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: rav3n at Nov 16, 2010, 07:09 AM

        btw, i checked source code and there’s following comment: &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}` <-- this would not work, json_decode won’t parse that
        Does this not work?
        &where=`[{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}]`
          • 21800
          • 174 Posts
          Hello,
          I’ve trouble whith some simplier item: so I’m trying to translate the Ditto filter "filter:Vstart,@EVAL return time();,6time();,6" to a Revolution code.
          i.e. "&where=`[{"publishedon:>=":"@EVAL return time();"}]`" did not work for me.
          I need it for filtering upcomming events.
            • 22303 MODX Staff
            • 10,725 Posts
            @EVAL does nothing except in Template Variables; you’ll need to return the time from a snippet.
              • 21800
              • 174 Posts
              Ok, that did it, it’s so great working with modX, thank you.

              [{"publishedon:>=":"[[now]]"}]

              snippet "now": <?php if(!isset($ts)) { $ts=time(); } return $ts;