We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46950
    • 86 Posts
    I use the function getImageList to output some data and I want to output only the lines where the field 'num' is less than 10. So I tried to compose this condition (as you can see below) but I guess I made some mistakes... but it outputs all lines! Unfortunately, I couldn't find in the Internet any description of how to form conditions in getImageList sad

    My attempt looks like:
    <table cellspacing=0 cellpaddling=10 border=1>
    [[getImageList?&tvname=`prices`&tpl=`pricesTpl`&where=`{"[[+num]]" lt "10"}`]]
    </table>
    

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

      • 4172
      • 5,888 Posts
      try
      &where=`{"num:<":"10"}`
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 46950
        • 86 Posts
        Quote from: Bruno17 at Nov 24, 2014, 07:49 AM
        try
        &where=`{"num:<":"10"}`
        Thanks, now it works! But what do all these colons mean?
          • 4172
          • 5,888 Posts
          this is a json-style array (key/value - pairs)
          http://www.json.org/

          the key is delimted by ':'
          first part - the fieldname
          second part - the operator

          possible operators, see:
          https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1966

          the value is the value, you are searching for.

          the syntax is nearly the same as in getResources or many other snippets where-property
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 46950
            • 86 Posts
            Quote from: Bruno17 at Nov 24, 2014, 08:57 AM
            this is a json-style array (key/value - pairs)
            http://www.json.org/

            the key is delimted by ':'
            first part - the fieldname
            second part - the operator

            possible operators, see:
            https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1966

            the value is the value, you are searching for.

            the syntax is nearly the same as in getResources or many other snippets where-property
            Thanks, nice! Looks like the condition I need could be written in this way, too? --
            &where=`{"num:lt":"10"}`
            


            And now the next condition I need is (when written in PHP style) "if($num>=10&&$num<20)". Is it possible to write it in &where=`{...}`?
            • discuss.answer
              • 4172
              • 5,888 Posts
              this should work:
              &where=`{"num:>=":"10","num:<":"20"}`
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 46950
                • 86 Posts
                Quote from: Bruno17 at Nov 25, 2014, 12:33 AM
                this should work:
                &where=`{"num:>=":"10","num:<":"20"}`
                Yeah, it's magic, it works! Thank you very much! smiley
                  • 41294
                  • 34 Posts
                  Is there any way this works with having multiple categories on each items?

                  Example i have categories "Category 1, Category 2, Category 3, Category 4, Category 5"

                  Now on my MIGX items, i can tag each item with categories above (i.e. Category 1, Catgory 2) using multilist tv with output separator with comma (,).

                  So let say on item 1, i have selected 3 categories on tv named [tags] so the value would be
                  [tags] => Category 1, Category 2, Category 3


                  Let say i would like to filter my MIGX items with tags, on my URL it will be
                  http://www.site.com/gallery/?tags=Category+1


                  and my MIGX snippet is
                  [[getImageList? &tvname=`gallery` &tpl=`gallery-tpl` &where=`[[!FilterTags]]`]]


                  Here's my FilterTags snippet;

                  $output = '';
                  
                  if(isset($_GET['tags'])) {
                  	$tag = $_GET['tags'];
                  	$output = '{"tags:LIKE":"%'.$tag.'%"}';
                  }
                  
                  return $output;


                  but this doesn't seem to work. Any idea why? or what did i miss? Thanks smiley
                    • 41294
                    • 34 Posts
                    Quote from: aerosko0315 at Jun 03, 2015, 07:21 PM
                    Is there any way this works with having multiple categories on each items?

                    Example i have categories "Category 1, Category 2, Category 3, Category 4, Category 5"

                    Now on my MIGX items, i can tag each item with categories above (i.e. Category 1, Catgory 2) using multilist tv with output separator with comma (,).

                    So let say on item 1, i have selected 3 categories on tv named [tags] so the value would be
                    [tags] => Category 1, Category 2, Category 3


                    Let say i would like to filter my MIGX items with tags, on my URL it will be
                    http://www.site.com/gallery/?tags=Category+1


                    and my MIGX snippet is
                    [[getImageList? &tvname=`gallery` &tpl=`gallery-tpl` &where=`[[!FilterTags]]`]]


                    Here's my FilterTags snippet;

                    $output = '';
                    
                    if(isset($_GET['tags'])) {
                    	$tag = $_GET['tags'];
                    	$output = '{"tags:LIKE":"%'.$tag.'%"}';
                    }
                    
                    return $output;


                    but this doesn't seem to work. Any idea why? or what did i miss? Thanks smiley


                    -----------------------

                    I was able to find a solution: instead of using LIKE, i used FIND. Example: {"tags:find":"value_here"}