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

    Can't seem to get getResources working with tvFilters at all, and its driving me insane!

    I'm just trying the get a resource to appear if the checkbox is checked. Simple? No!

    TV Name: featuredTV
    Input Type: Check Box
    Input Option Values: featuredTV==1
    Default Value: 0
    Output Type: Default

    My getResources call looks like:

    [[!getResources? &parents=`23,24` &limit=`3` &includeTVs=`1` &tvPrefix=`tv` &tvFilters=`featuredTV==1` &tpl=`featuredEventsTpl`]]


    I've tried without the tvPrefix, and without the includeTVs. No good.

    It works without the tvFilters, so I must be going wrong somewhere.

    Any help would be very appreciated!

    Thanks
      • 3109 ☆ A M B ☆
      • 894 Posts
      Try adding
       &processTVs=`1`
      to the getResources call and it should work, you can also add
       &showHidden=`1`
      if your resources are hidden and you want to access them and maybe get rid of the limit otherwise it won't show you only the first 3 template variables.

      Hope that helps.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 22303 MODX Staff
        • 10,725 Posts
        FYI, processTVs, includeTVs, and tvPrefix have no relation to tvFilters and do not affect the results. tvFilters is criteria for selection of Resources only; the other TV-related properties are for rendering TV values in getResources tpl's and do not affect selection of Resources in any way.
          • 3109 ☆ A M B ☆
          • 894 Posts
          @open geek thanks for clarifying that I always thought that in order to retrieve TV you needed those.

          Thanks.
            Benjamin Marte
            Interactive Media Developer
            Follow Me on Twitter | Visit my site | Learn MODX
            • 27106
            • 147 Posts
            neilp123, did you have any luck yet? I'm also struggling with a couple of issues around tvFilters at the moment which sound much like yours - hence I'm airing them here.

            I have a radio button TV set either to "yes" or "no". (It was set to 1 or 0, but that created some strangeness of its own - 0 wouldn't register as a value.)

            Using getResources to list articles, I can see the "yes" and the "no" resources. I've dumped the array to double-check what the records show. But as soon as I add
            &tvFilters=`myTV==%%`
            into the call, all the resources with "yes" values disappear. Using
            &tvFilters=`myTV==no`
            in the getResources call returns the same set - all the records for which the value is "no". Using
            &tvFilters=`myTV==yes`
            returns nothing.

            neilp123, does your getResources call work with the tvFilters parameter removed?

            Is there any chance this is a bug?

              David Walker
              Principal, Shorewalker DMS
              Phone: 03 8899 7790
              Mobile: 0407 133 020
              • 27106
              • 147 Posts
              OK, more trawling in the forums produced what I think is the answer, courtesy of Bruno17:
              http://ttyl.modx.com/thread/12904/filtering-the-result-returned-by-getresources#dis-post-71993

              neilp123, let us know if this works for you.

              Summary: If you're thinking of filtering on a radio button TV field, make sure your default is left blank. The tvFilter ignores default values. You have to set all your TV values explicitly to non-default values, or your filtering will silently and mysteriously fail ... and then your head will explode.

              Why does MODX do it this way? Because, says opengeek, processing every instance of a TV in order to filter on the processed value is "horribly inefficient". Fair enough.

              But it would be nice to have someone pop this little detail into the tvFillters documentation so that people like me and Neil don't go splattering brain tissue over our loved ones.
                David Walker
                Principal, Shorewalker DMS
                Phone: 03 8899 7790
                Mobile: 0407 133 020
                • 3109 ☆ A M B ☆
                • 894 Posts
                File it as a doc improvement request here it's the only way MODx docs will improve.
                  Benjamin Marte
                  Interactive Media Developer
                  Follow Me on Twitter | Visit my site | Learn MODX
                  • 27106
                  • 147 Posts
                  benmarte, great suggestion and thanks for the pointer.

                  I had no idea that you could file doc improvement requests. It turns out that at the URL you provided, one of the open tasks is "Document how to contribute to the documentation". Heh.
                    David Walker
                    Principal, Shorewalker DMS
                    Phone: 03 8899 7790
                    Mobile: 0407 133 020
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Actually, the most recent releases of getResources do work when using tvFilters against default TemplateVar values.
                      • 21122
                      • 153 Posts
                      Hi all,

                      Finally have it working thanks to that other thread. I'm now using radio buttons instead of a checkbox, and followed the instructions shown on that thread pretty much to the letter.

                      David - if you're still struggling, pop my an PM and I'll help you out.

                      And i agree, could really do with some more documentation on this subject!