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

    I just puzzle with a date modifier.

    In a Ditto call I collecte some "news" article wich should have an event date.
    During the 1st phase of site building I used
    [+createdon:date=`<span class="jour">%a.</span ><span class="month">%b.</span ><br /> <span class="day">%d </span >`+] 

    wich was ok (the date in the ditto tpl was returning fine.

    Now I need to use a real value, setup by a redactor, and I wanna use a TV [*date-event*] instead.
    (with date formatter widget and %d %m %Y format)

    However the output from Ditto is now a 1/1/70 date now whatever I put in my TV (A direct TV output in a page by the template, shows of course a correct value)

    the Ditto call is :
    [[Ditto? &id=`69` &parents=`69` &display=`6` &extenders=`summary,dateFilter` &truncSpli=`0` &truncOffset=`55`  &tagData=`documentTags` &sortBy=`date-news` &dateSource=`date-news` &dateSource:date=`%a` &dateSource:month=`%b` &dateFormat=`%d/%m/%Y` &language=`francais-utf8` &truncText=`lire...` &tpl=`ditto-news.tpl`]]


    What’s wrong ?
    thank you
      Schtroumpf Grognon - Grouchy Smurf
      ---------------------------------
      Faites pas attention.. - Don&#39;t pay attention
      http://www.dzi-neo.net
      • 26016
      • 561 Posts
      Salut,
      I tried to use the Date Formatter widget sometime ago, and I never got it to work, I got the same result as you. I just assumed it was broken.

      Sorry, that doesn’t help much, but maybe somebody else may know more about this, or know how to get it to work.

      Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 16278
        • 928 Posts
        You have to use the Unixtime widget in your date TV. Ditto expects to receive dates in Unix timestamp format. createdon and other built-in date fields are stored in this format in the first place, but TVs need to have their output format converted by the widget.
        smiley KP
          • 8790
          • 526 Posts
          Grmll...
          That’s precisally what I dont want Afaik
          One have to think User side

          A date picker for redactor is a must and it’s obvious they won’t type a timestamp.
          Plus there’s always need to format this date (localisation for ex)

          So what is the interest to have a date widget of it cant be use widely
            Schtroumpf Grognon - Grouchy Smurf
            ---------------------------------
            Faites pas attention.. - Don&#39;t pay attention
            http://www.dzi-neo.net
            • 22427
            • 793 Posts
            As far as I see this is not correct:
             &dateSource:date=`%a` &dateSource:month=`%b`
            You can’t use modifiers in that way, and the modifier [tt]month[/tt] doesn’t even exist.

            The [tt]date[/tt] modifier is only applicable to the date TV, that is in that way:
            [tt][+date-news:data=`%d %m %Y`+][/tt] .

            And the place for this is the template!
            So you have to put [tt][+date-news:data=`%a`+][/tt] at the wanted position in your template, and [tt][+date-news:data=`%b`+][/tt] at another one.
              • 8790
              • 526 Posts
              ottogal:

              Thank you, but yes...

              I used this in the Ditto tpl
              [*createdon:date=`<span class="jour">%a.</span ><span class="month">%b.</span >
              <span class="day">%d&nbsp;</span >`*]
              I tried to convert into:

              [*date-news:date=`<span class="jour">%a.</span ><span class="month">%b.</span >
              <span class="day">%d&nbsp;</span >`*]
              this is my initial post.

              The point is that the date modifier and all snippets are supposed to work with unix timestamp format and not with string format coming from the Date formatter widget, as I thought it was needed to give a date picker to the redactor.

              I was wrong : a unixtime format keeps the date picker too, so the date is ok and handled by the modifier now!
              BUT it’s not utf8 I have issues with accentuated characters in the months now...
              +
              Ditto does not see my date tv in its loop (still 1/1/70)
              edit :in fact Ditto sees only the CURRENT page TV value, not the one in runs over. Even with :
              [*phx:input=`[*date-news*]`:date=`<span class="jour">%a.</span ><span class="month">%b.</span ><br /> <span class="day">%d </span >`*
                Schtroumpf Grognon - Grouchy Smurf
                ---------------------------------
                Faites pas attention.. - Don&#39;t pay attention
                http://www.dzi-neo.net
                • 4172
                • 5,888 Posts
                try it this way:

                <span class="jour">[+date-news:date=`%a.`+]</span >
                <span class="month">[+date-news:date=`%b.`+]</span ><br /> 
                <span class="day">[+date-news:date=`%d`+] </span >
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 8790
                  • 526 Posts
                  I got it:

                  Here’s the way:

                  Ditto does not parse a TV value, I remembered, a long time ago, we had to use instead of
                  [*Thetvname*] 
                  :
                  [+tvThetvname+] 
                  to make it parsed in the Ditto loop.
                  That’s it!

                  But I still had an utf8 error and French months names were corrupted when they contains accentuated car.(only in the ditto tpl, not in a page tpl)

                  I had to add :
                  setlocale(LC_ALL, "fr_FR.utf8");

                  1st line into dateFilter.extender.inc.php (Ditto files in /snippets/ditto/extenders/)

                  pff!...
                  this thread should be useful for some..
                  Thanks
                    Schtroumpf Grognon - Grouchy Smurf
                    ---------------------------------
                    Faites pas attention.. - Don&#39;t pay attention
                    http://www.dzi-neo.net
                    • 4172
                    • 5,888 Posts
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!