We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    The Ditto snippet automagically takes content from every document in the folder you tell it to use, this replaces the [+summary+] tags. You can use the "summary" (introtext) field of the documents, or you can have it take a certain number of characters from the main content of the documents.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 33372
      • 1,611 Posts
      Rather than keep pounding my face into the keyboard until this works the way I’d expect, I think I’ll try asking some folks who know how it really works...

      I’m trying to filter by a TV, and I’m always getting "No entries found". The TV in question is a multi-select listbox, but I’ve tried using simple text TVs also and there was no change. My snippet call is the following:

      [!Ditto? &startID=`4` &tpl=`ShopXCategory` &summarize=`20` &truncSplit=`false` &sortby=`menuindex` &sortdir=`asc` &showInMenuOnly=`1` &filter=`tvitemStyles,pajama,1` &hiddenTVs =`itemStyles`!]


      I’ve tried several variations of this, but apparently not the correct one. Anyone see what I’m doing wrong? If so, please let me know.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 33372
        • 1,611 Posts
        Hmm...

        Still no luck. The filter var just doesn’t seem to be working with my TVs at all. If I remove the filter, I get results; with any TV filter I get "No entries found".

        I’ve tried adding [+tvitemStyles+] to the template chunk and removing the hiddenTVs var, but no change.

        Is the filter var broken for TVs, or am I just doing it wrong?

        I need lists of docs with specific TV values, so I’m gonna write me a hack if I don’t hear some Ditto good news soon...
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn't very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 33372
          • 1,611 Posts
          OK I got it to work the way I wanted, but I did have to hack the code a little bit. So either I’m doing something the hard way or I’m doing something new. I don’t know which; I’m just glad it works now.

          My problem was that I have multi-listbox selector TVs, and I couldn’t get any of the existing filter methods to work when more than one item was selected in them. So I was looking for "pajama" in a TV that also contained "robe" and "sleep-shirt" (yes, it’s a pajama website - got a problem with that? wink ), but Ditto wasn’t finding it unless just "pajama" was selected in the document. So I created a new filter method (lucky number 7) that uses strpos() to see if the string exists in the TV output.

          My snippet call is like this:
          [!Ditto? &startID=`4` &tpl=`ShopXCategory` &summarize=`999` &truncSplit=`false` &sortby=`menuindex` &sortdir=`asc` &showInMenuOnly=`1` &hiddenTVs =`itemStyles` &filter=`tvitemStyles,pajama,7`!]


          And in ditto.class.inc.php I added the following to the end of the case statement in the basicFilter function:
          				case 7 :
          					if (strpos($value[$this->array_key], $this->filterValue)===FALSE)
          						$unset = 0;
          					break;


          Dunno if this will help someone else, but it’s working for me.
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 33372
            • 1,611 Posts
            And of course, as I knew would happen sooner or later, I found I needed the opposite method (string not found in field), so I added a case number 8 as well:

            				case 8 :
            					if (strpos($value[$this->array_key], $this->filterValue)!==FALSE)
            						$unset = 0;
            					break;
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn't very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 18397
              • 3,250 Posts
              You are correct in that filter modes one and two look for the exact entire string and not just a selection. Your solution is so elegant, would you mind if I included it in Ditto 1.1 Final?
                • 33372
                • 1,611 Posts
                Of course not - it’d be an honor to have a couple lines of code in such a great snippet!
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 17895
                  • 209 Posts
                  Can I use "publish date" and if it isn’t set, Ditto automatically read "created date"?
                    Daniele "MadMage" Calisi
                    • 18397
                    • 3,250 Posts
                    Yes, with 1.0.2 or 1.1b2
                      • 18397
                      • 3,250 Posts
                      This thread is now locked as Ditto 1.0 is deprecated.

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