We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38525
    • 26 Posts
    Hi all,

    I'm having trouble getting the &where filter to work with an image slider... I want to load the items based on whether or not a checkbox is selected, but it doesn't recognize any of the combinations I've tried.

    The getImageList call:
        <div id="nieuws-viewer">
          <div id="slider">
            <ul>
    [[!getImageList?
       &tvname=`sidebar_viewer`
       &tpl=`viewerTpl`
       &where=`{"display:IN":"home"}`
    ]]
            </ul>
          </div>
        </div>
    


    The sidebar_viewer TV form tabs:
    [
    {"caption":"Eigenschappen van dit viewer item", "fields": [
        {"field":"image", "caption":"Afbeelding", "inputTV":"sidebar_viewer_image"},
        {"field":"title", "caption":"Titel"},
        {"field":"description", "caption":"Omschrijving"},
        {"field":"link", "caption":"Link", "inputTV":"sidebar_viewer_url"},
        {"field":"display", "caption":"Weergave", "inputTV":"sidebar_viewer_display"}
    ]}
    ]
    


    The viewerTpl:
              <li>
                <img src="[[+image]]" width="208" height="138" alt="[[+description]]">
                <span><a href="[[+url]]"><strong>[[+title]]</strong><br />[[+description]]</a></span>
              </li>
    


    The slider is working just fine without the &where property. I've tried referring directly to the TV {"sidebar_viewer_display":"home"}, turned delimiters off and on, tried basic things like {"title":"1"}, but nothing works...

    By the way, in all cases it does output the contents of viewerTpl in the HTML, but always only once and without its placeholders filled:
        <div id="nieuws-viewer">
          <div id="slider">
            <ul>
              <li>
                <img src="" width="208" height="138" alt="">
                <span><a href=""><strong></strong><br /></a></span>
              </li>
            </ul>
          </div>
        </div>
    


    Additional info: using Revo 2.2.0-pl2 and the latest MIGX package. Anyone got a clue what I'm doing wrong here?
      • 23018
      • 353 Posts
      @Suikerzout

      I think you have to use "FIND" instead of "IN". As far as I know this operator is not included in the latest official release. You could try the latest version form github.

      Backup /core/components/migx/model/migx/migx.class.php

      and get the latest version from github:
      https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php

      As long as you habe only one item among your checkboxes checked you should be good to go.

      If multiple checkboxes are checked it seems to broken. I can read the responsible lines as often as I want.

                          case 'find':
                          case 'find_in_set':
                              $subject = explode(',', $subject);
                              $output  = in_array( $operand , $subject ) ? $then : (isset($else) ? $else : '');
                              break;
      


      They look fine to me but they don't do what they are supposed to do.

      Example I have a MIGX TV with a range of checkcboxes: red||blue
      The outpult is delimited by a ","

      I have a MIGX Grid with three entries:

      1. red and blue are checked. Output: red,blue
      2. red is checked. Output: red
      3. blue is checked. Output: blue

      Using

      &where=`{"colors:find":"red"}`
      


      should return row 1 and 2, because in both of them the red checkbox is checked.

      I only get row 2 though.

      Should be piece of cake. Don't know where I'm wrong here.

      Regards,

      pepebe [ed. note: pepebe last edited this post 12 years, 2 months ago.]
        Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
        • 38525
        • 26 Posts
        Thanks for the help pepebe!

        I downloaded the code from github, and now both :in and :find are working like you said (if only one checkbox is selected). I think with an extra TV I can now manufacture what I want to do...

        Unfortunately I am a lousy programmer, so I can't help you any further with that piece of code... Should be great if someone else could get that working though!
          • 23018
          • 353 Posts
          OK, this is what I have found out. Somehow $subject which is the content of $item[$field] doesn't contain whats supposed to be inside (in my case a comma delimited list of zero or more colors).

          If I use [+output] to print the content of the tv into the tpl the comma IS there. So it SHOULD also be inside filterItems() when I use explode() to transform the list into an array and then use in_array() to find out whether the operand can be found inside or not.

          It doesn't work.

          As far as I understand, the comma is not there and therefore explode() doesn't work.

          I'll futher invesigate into that topic.

          'Regards,

          pepebe

            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
            • 38525
            • 26 Posts
            Could there be a way to somehow ignore the delimiter and look for a specific part in the outputted line, just like with output modifiers? For instance, if you have an output of "redgreenblue", pick the green out like &where=`{"colors:find":"%green%"}`? This example doesn't work btw wink

              • 30319
              • 406 Posts
              Quote from: Bruno17 at Feb 19, 2012, 07:35 PM
              Quote from: MokoJumbie at Feb 19, 2012, 05:12 PM
              I am having a problem (possibly) related to the one TomMLS is having. I submitted an issue on github about it.

              the paths for file-based TVs are being prepended with './' so an expected path of 'image.jpg' is saved as './image.jpg'. The path is rendered on the front end as 'media_source/./image.jpg'

              I'd be curious to know in TomMLS' case if the TV value containing the full URL is being generated by MIGX or due to some configuration issue.

              Tom, can you tell us about the Media Source you are using for that TV? What are the baseUrl and basePath vaules, and is your modx install in your site root? Also, what kind of values are being generated by ImageTVs outside of MIGX? Are they full, absolute or relative paths?

              do you have the same or a different result with image-TVs outside of MIGX and inside of MIGX ?

              SAME result with image-TV outside of MigX and inside of MigX
              basically it's prepending the context folder name to the image url
              output result is set to default
              will continue reading this thread etc.
              on the page testing the TV I get

              image: /foundation/http://mls2/media/foundation/images/00-test-images/Jan-20th,-2011-004.jpg

              Upon further experimentation with paths etc. for the media source (what backslashes to use etc.) I can get phpthumbOf to correctly find and display the desired images within the template variables TAB within the manager while editing etc., but the images still do not display correctly in the browser after clicking View...

              revo 2.2-pl2 with migx 2.0-beta1

              by making the media source 'absolute' I can get the media source images to properly display from the MigX call BUT they are not visible in the template variable section and neither is the media source...must drill down into filesystem...

              Thank you, Tom [ed. note: TomMLS last edited this post 12 years, 2 months ago.]
                • 23018
                • 353 Posts
                Today I noticed an error in my error log:

                [2012-02-23 10:31:22] (ERROR @ .../core/cache/includes/elements/modsnippet/44.include.cache.php : 261) PHP warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed

                As far as I can tell this error is only thrown if a page is rendered that has not been cached beforehand.

                Looking up the cached file I relalized it is related to line 261 inside the getImageList snippet:

                $o = implode($outputSeparator, $output);


                It's seems SOMETIMES $output is not an array, because wrapping this line into

                    if( is_array($output) ){
                	$o = implode($outputSeparator, $output);
                    }
                    else {
                    	$o = $output;
                    }
                


                Seems to fix this problem.

                I don't have any idea why this happens, because line 161 says

                $output = array()


                So this should'nt happen in the first place.

                Please check you error log for similar messages, so I can be sure it's not caused by something I did to my MODx installation.

                Regards,

                pepebe
                  Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                  • 38525
                  • 26 Posts
                  Pepebe, my error log is showing these errors too...
                    • 4172
                    • 5,888 Posts
                    if( is_array($output) ){
                    $o = implode($outputSeparator, $output);
                    }
                    else {
                        $o = $output;
                    }
                    



                    hmm.. can't see a reason, why $output shouldn't be an array here, but if that really helps, I will add this to the getImageList-snippet.
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 23018
                      • 353 Posts
                      @bruno: I don't understand it either. It shouldn't happen, but it does.

                      Seems we have a severe case of Gremlins running havoc in your code.

                      If this fixes the whole issue, I don't mind...

                      Regards,

                      pepebe
                        Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe

                      This discussion is closed to further replies. Keep calm and carry on.