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

    Have recently used Ditto to create an ’upcoming events’ listing system for a centre, and this has all gone down very well indeed. Initially my plan was for them to either use unpublish dates or delete documents after the event had finished, however they have asked if it is possible to have the events auto-archived after they event had started.

    This to me seems like it should be easy enough using the filtering options available in Ditto and either two ditto calls (one on upcoming events and other in past events) or a Ditto and a Reflect, either way.

    Using this call
    [!Ditto?&debug=`1`&filter=`SortingDate, '@EVAL return time()',3`&extenders=`dateFilter`&sortDir=`ASC` &parents=`[*id*]` &summarize=`10` &tpl=`EventEven`&tplAlt=`EventOdd`&sortBy=`SortingDate` &paginate=`1` &alwaysshow=`1` &tplLast=`EventOdd`!]

    I receive all my documents, including the test one on the past. Changing filter mode to 4 i get no documents at all. Have tried both cached and uncached with the same results.

    Have tried using <?php ?> to wrap the time request, using @EVAL as you see and @CODE, also just leaving it as return time()/ time() by itself, so i am wondering if this functionality is actually built into the ditto filtering system, if so what am i doing wrong? I have read through the available documentation at the ditto subdomain and the wiki but i can’t tell if this is going to work from what is currently documented about filtering.

    If this is not possible i know i could setup a tv with the time call inside, lock it so that people dont play with it and just call it current time, but is it possible to then filter by comparing those two tv’s? ie. if SortingDate>CurrentTime then display.

    The versions i am using are the latest SVN (2 revisions after Ditto 2.0) and Modx0.9.5

    Appreciate that you are busy and sorry if this is a simple issue with a fix i have overlooked somewhere,
    Thanks
      • 18397
      • 3,250 Posts
      No, @EVAL is not in the Ditto filtering system although that is a good idea. Please file a feature request for it.

      Now, on to the solution. The quick way is to create a snippet called time with return time(); as the code and then simply call it as the second parameter. Make sure to alternate cached and uncached snippet calls.

      "is it possible to then filter by comparing those two tv’s? ie. if SortingDate>CurrentTime then display." Again, Ditto can’t do that but that is a great idea! Please file a feature request for it.
        • 26693
        • 23 Posts
        Thanks Mark the snippet idea solved that little hiccup, also filed two separate requests for those features in the ditto ticketing system. Look forward to seeing them implemented in the future!
          • 18397
          • 3,250 Posts
          I implemented @EVAL in changeset 1377. You can get a copy from the Development Download link on http://www.modxcms.com. Please give it a try and let me know if it works. Remember, you need to return the output. It may be easier to handle multiline statements by adding it to the parsedFilters array in an new extender or config file.

          As for the tv (or field like id) comparison, can anyone provide a good example of where this would be useful? Implementing this natively would mean that if someone had one tv and they wanted it equal to value but it had a name of a real tv that their filter would fail. I could use an @TV prefix but that would kind of be backwards now wouldn’t it...
            • 26693
            • 23 Posts
            Couldn’t find developers download link on the home page, but using Tortoise got me changeset 1377 from /trunk.

            @EVAL now works perfectly for me, using mode 3 i get all the events after the current unix time, using mode 4 i get all the events before the current unix time, amazingly useful implementation when fully utilized im sure.

            Thanks Mark.
              • 18397
              • 3,250 Posts
              Its the last item on http://modxcms.com/ditto "Development Download" which links to http://modxcms.com/ditto_download.html

              Glad to hear it is working. Are all other features, including the debug console, working for you?
                • 26693
                • 23 Posts
                Yup the debug console is working nicely as far as i can tell, when i used the [[Time]] snippet you suggested it displayed the current time in the filter tab, at the moment it shows source = SortingDate, Value = @EVAL return time();, mode =3. Which one is as working as intended im not sure, but the functionality works fine either way.

                  • 18397
                  • 3,250 Posts
                  Displaying whatever you input is the intended functionality. If you enter a snippet, it will be parsed before Ditto sees it, thus the value will already be there.