We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39501
    • 163 Posts
    @bruno17 - thank you so much - that worked!!!

    Just got to get getimagelist to work with geturlparam / if statement and i'm there! Current [if] statement displays only 1 news article when there are 2.

    • discuss.answer
      • 4172
      • 5,888 Posts
      and here is a bit more flexible filter-snippet:

      <?php
      
      if (!is_array($subject)) {
          $subject = explode(',',str_replace('||',',',$subject));
      }
      
      return (in_array($operand,$subject));


      this should handle arrays, comma-delimited, double-pipe-delimited and sinlge-word tags
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 39501
        • 163 Posts
        @bruno17 - Thanks once again for your help.

        If I put this call on a page:
        [[getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news` &where =`{"tags:snippet:filterbytag":"announcement"}`]]

        It returns all values with the tag 'announcement'.

        If I try it conditionally:

        [[!If?
        &subject=`[[!getUrlParam? &name=`tag` &int=`0`]]`
        &operator=`news`
        &then=`[[getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news` &where =`{"tags:snippet:filterbytag":"news"}`]]`
        ]]

        It only returns one item. Any ideas? I have stripped back my getimagelist tpl to make sure there is no conflicts.
          • 4172
          • 5,888 Posts
          does it work, when you call it this way:

          [[!getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news` &where =`{"tags:snippet:filterbytag":"[[!getUrlParam? &name=`tag` &int=`0`]]"}`]]


          and make sure to call it uncached since the result is dynamic.

          If you want to have cached results for each tag you can try to wrap it by getCache:
          https://github.com/opengeek/getCache [ed. note: Bruno17 last edited this post 11 years, 3 months ago.]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 39501
            • 163 Posts
            It does but for some reason i get a double output (should be 2) but I get 4

            update: it did work! had a hidden snippet in my code that i thought was commented out, hence the duplication smiley [ed. note: jonleverrier last edited this post 11 years, 3 months ago.]
              • 39501
              • 163 Posts
              Thanks so much for your help Bruno smiley All working nicely now!

              I'm using IF to display the results un-filtered on the news page, and if there is a filter applied to the URL, display the filtered results:

              [[!If?
              &subject=`[[!getUrlParam? &name=`tag` &int=`0`]]`
              &operator=`notempty`
              &then=`[[!getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news` &where =`{"tags:snippet:filterbytag":"[[!getUrlParam? &name=`tag` &int=`0`]]"}`]]`
              &else=`[[!getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news`]]`
              ]]
              


              Not sure I could of done this IF statement with output modifiers. Any way, thanks again Bruno smiley
                • 4172
                • 5,888 Posts
                this will process the snippet-call twice each time.

                you can try it also this way:

                [[[[!If?
                &subject=`[[!getUrlParam? &name=`tag` &int=`0`]]`
                &operator=`notempty`
                &then=`!getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news` &where =`{"tags:snippet:filterbytag":"[[!getUrlParam? &name=`tag` &int=`0`]]"}``
                &else=`!getImageList? &tpl=`plug.tpl.news.item` &tvname=`tv.migx.news``
                ]]]]


                or this:
                [[!getImageList? 
                &tpl=`plug.tpl.news.item` 
                &tvname=`tv.migx.news`
                [[!If?
                &subject=`[[!getUrlParam? &name=`tag` &int=`0`]]`
                &operator=`notempty`
                &then=`&where =`{"tags:snippet:filterbytag":"[[!getUrlParam? &name=`tag` &int=`0`]]"}``
                &else=``
                ]]
                ]]


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

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 39501
                  • 163 Posts
                  Didn't realise you could nest IF statements in between snippet calls smiley

                  I've just tried adding 2 tags to one post "news, thoughts". For some reason MIGX still treats this as 1 string.

                  I filter by news and the tag with news (and thoughts) is excluded. I filter for thoughts, and there are no results.