We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24495
    • 407 Posts
    I have a travel page (http://www.koegel-touristik.de/reisen.html) with travel documents and sub-documents for each travel date.
    The dates are published by a Ditto call with a date filter to hide all elapsed dates:
    [[Ditto? &tpl=`terminListing` &display=`all` &depth=`1` &orderBy=`terminAnfang ASC` &language=`german` &noResults=`<li>Reisetermine abgelaufen</li>` &filter=`terminAnfang,@EVAL return time();,3`]]

    The date TV "terminAnfang" contains the date with the time when the date was created (Often I forget setting the time to 00:00:00).

    Is there a way to extend the filter clause for a result ignoring the time information? My problem is: I wish to hide all dates older then today. But the date will be hided exactly at the date AND time (and this can be in the evening). I wish to hide the date at 00:00:00 independently of the real time information in the TV.
      • 4172
      • 5,888 Posts
      you can try this:
      [!makedatefilter? &datetv=`[*terminAnfang*]`!]

      snippet makedatefilter:

      $dateday = strftime("%d", $datetv);
      $datemonth = strftime("%m", $datetv);
      $dateyear = strftime("%Y", $datetv);
      $thedate = mktime(0, 0, 0, $datemonth, $dateday, $dateyear);
      $now=time();
      $dateday = strftime("%d", $now);
      $datemonth = strftime("%m", $now);
      $dateyear = strftime("%Y", $now);
      $nowdate = mktime(0, 0, 0, $datemonth, $dateday, $dateyear);
      return '&filter=`'.$thedate.','.$nowdate.',3`'
      ;

      or make a PHx modifier of this kind, works this for you?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 7231
        • 4,205 Posts
        I did not understand the solution rolleyes My German is a little rusty grin
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 24495
          • 407 Posts
          @dev_cw: Bruno17 means that I should use a snippet for the filter clause. I must try this. Don’t know wether it works in a Ditto call. Will reply the result this day.

          EDIT: @Bruno17: nice idea but doesn’t work.
            • 4172
            • 5,888 Posts
            What is the output of the snippet, if you call it alone?

            what is, when you use
            $filter=$thedate.','.$nowdate.',3';
            $modx->setPlaceholder('filter', $filter);
            return;

            instaed of
            return '&filter=`'.$thedate.','.$nowdate.',3`'

            and then
            &filter=`[+filter+]` 

            in the Ditto-Call?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 24495
              • 407 Posts
              The snippet itself works fine. But as a filter in all versions it doesn’t work.

              Working itself needs a little modification:
              $id = (isset($id))? $id : $modx->documentIdentifier;
              $tv = $modx->getTemplateVar('terminAnfang',"*",$id);
              $datetv = $tv['value'];
              $dateday = strftime("%d", $datetv);
              $datemonth = strftime("%m", $datetv);
              $dateyear = strftime("%Y", $datetv);
              $thedate = mktime($dateyear,$datemonth,$dateday,0,0,0);
              $now=time();
              $dateday = strftime("%d", $now);
              $datemonth = strftime("%m", $now);
              $dateyear = strftime("%Y", $now);
              $nowdate = mktime($dateyear,$datemonth,$dateday,0,0,0);
              return '&filter=`'.$thedate.','.$nowdate.',3`'
                • 7231
                • 4,205 Posts
                Make sure to alternate the cache settings of the snippet calls [[Ditto?..[!FilterSnippet?..!]` ]] (or the other way around). Another option would be to use a wrapper snippet to both evaluate the filter clause and then run Ditto. This would avoid cache parsing issues.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 4172
                  • 5,888 Posts
                  hmm... and what is with the datefilter-extender thing?
                  perhaps is that the thing which does the job?

                  I know...........my englisch is so bad!

                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 24495
                    • 407 Posts
                    Seems that I need an extender. Will try this next time. Thanks for your ideas.