We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19004
    • 33 Posts
    I have a setup like the following:

    Products
    - Category 1
    - Item 1
    - Item 2
    - Item 3
    - Category 2
    - Category 3

    And so on. The "item" pages have a TV named "product_featured" which is either 1 or 0. On the main products page I use this call to try and pull the featured products:

    [!Ditto? &startID=`4` &depth=`2` &summarize=`100` &tpl=`ProductHTML` &hideFolders=`1` &hiddenTVs=`tvproduct_featured` &filter=`tvproduct_featured, 1, 2`!]


    The issue is that Ditto fails to properly filter out pages that lack the TV "product_featured" in them. Since the filter is an explicit request for an equals, the intuitive behavior would be for it to ditch all results that did not meet the requirements. I don’t know if this is a bug or a feature, or if I’m just doing something wrong, but it keeps returning all of the Category pages as results, which it shouldn’t.

    The &hiddenFolders=`1` should take care of that yes, but the problem with that is that there is no guarantee that they won’t create a (temporarily) blank Category as a placeholder for upcoming content. In that case it is not listed as a folder, and it will suddenly show up as a broken featured product. I know that the user can forcibly call it a folder in the document properties, but these people aren’t going to do that. They are very low-level users and need to have everything work as seamlessly as possible.

    What do I do? I’m running Ditto 1.1 beta 2 if that makes a difference.
      • 11975
      • 2,542 Posts
      Hi,

      in the &hiddenTvs param, the tv prefix is not necessary.
      Try the same call without the prefix

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 19004
        • 33 Posts
        Hmm, still no difference.
          • 19004
          • 33 Posts
          Just as a note. If I change the 2 to =, it stops returning results, no matter if the criteria is matched or not. My guess is that is expected when calling Ditto from a chunk?

          EDIT: Okay, I solved my problem, but unfortunately the error does point back to Ditto. The solution was to just get rid of the ,2 entirely. Ditto apparently isn’t handling that last paramenter properly. I double-checked the snippet code to make sure that I was, in fact, using Ditto 1.1 beta2, and I was.

          I noticed that somebody else mentioned whacky behavior when using the number chart. Perhaps this is what they were referring to?
            • 11975
            • 2,542 Posts
            Have you tried to remove the space after each comma in your filter param

            &filter=`tvproduct_featured,1,2`

            :-)

            Edit:and don’t forget to remove the tv prefix from the hiddenTVs
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 18397
              • 3,250 Posts
              There should be no spaces after the commas. Secondly, you must use the numbers as MODx filters out the symbols.
                • 19004
                • 33 Posts
                I removed the spaces as part of my testing, with no effect. Using the numbers didn’t work, I had to get rid of the 2 to make it work.
                  • 11975
                  • 2,542 Posts
                  I guess you misundertsood how the filters work.
                  Ditto will remove every document from the list which matches the criteria.
                  So if you’re looking for every document where tv equal = 1
                  your filter will be `tv,1,1` which means remove every doc which a value for tv != 1

                  :-)

                  EDIT: that’s why when you remove the 2, you git the right result since 1 is the default value for filters
                    Made with MODx : [url=http://www.copadel.com]copadel, fruits et l