We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22915
    • 33 Posts
    I am running:
    MODx Revolution 2.0.0-rc-1 rev6614
    Ditto 3.0 Alpha 3

    The formatting is coming out "By Default Admin User on December 31, 1969 18:33." The publishedon date is not December 31, 1969, it is April 09, 2010

    [[Ditto? &parents=`11` &display=`2` &tpl=`ditto_news` &dateSource=`publishedon` &dateFormat=`%B %d, %Y %H:%M` &paginate=`1` &extenders=`summary` &paginateAlwaysShowLinks=`1`]]


    <div class="ditto_summaryPost">
      <h3><a href="[[ ~[[+id]] ]]" title="[[+title]]">[[+title]]</a></h3>
      <div class="ditto_info" >By <strong>[[+author]]</strong> on [[+date]]. </div>
      [[+summary]]
      <p class="ditto_link">[[+link]]</p>
    </div>


    Any thoughts?

    • Not sure; the dateFormat option may be broken in the Revo port. You can search for/report the problem at http://svn.modxcms.com/jira/browse/DITTO
        • 22915
        • 33 Posts
        I even tried it without the dateFormat option and it is still incorrect.
        • That usually means an unexpected input to the date formatting function.
            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
            • 22915
            • 33 Posts
            Does this mean I have something configured incorrectly or is it a Ditto bug?

            If I have something configured incorrectly. Can you point me in the right direction to fix it?
              • 8924
              • 10 Posts
              I have the same problem. I did a long search in internet and on modx forum like this post

              http://modxcms.com/forums/index.php/topic,31209.msg189265.html#msg189265
              but didn’t solve my problem either.

              I checked of course in phpmyadmin and found that the createdon date is 1271055226 that is april 12 2010 and so is for publishedon date. Since the database is ok maybe this is a problem related to ditto, for some reason, unable to read correctly from the db.

              Any clue to solve this annoying problem?

              Thanks EnumaElis

              I apologize. Is not a problem of ditto. I just created a TV named mia_data and set it to show the current date if no input date is given. Then I put it on a document to show the current date. The result was, incredibly, Thursday 01, January 1970. So the problem is in Revolution.
              • Quote from: enumaelis at Apr 12, 2010, 10:11 AM

                I apologize. Is not a problem of ditto. I just created a TV named mia_data and set it to show the current date if no input date is given. Then I put it on a document to show the current date. The result was, incredibly, Thursday 01, January 1970. So the problem is in Revolution.
                This is definitely a Ditto problem, related to the fact that MODx no longer returns these fields in UNIX timestamp format; these are returned in the standard MySQL datetime format and can be easily formatted with the strtotime and date output filters, i.e.
                [[+publishedon:strtotime:date=`%b %e, %Y`]]
                  • 8924
                  • 10 Posts
                  Maybe I’m wrong but looking at the db with phpmyadmin the createdon/publishedon/editedon date is in unix timestamp not in mysql timestamp, so the code in ditt.class.inc.php, calls the function strftime:

                  if (in_array("date",$this->fields["display"]["custom"])) {
                  			$timestamp = ($resource[$dateSource] != "0") ? $resource[$dateSource] : $resource["createdon"];
                  			$placeholders['date'] = strftime($dateFormat,$timestamp);
                  		}


                  The TV i created has nothing to do with ditto since is created via modx, but still has the same value.

                  Anyway there is another problem with ditto. I tried to pass the &tpl variable in ditto call with the following:

                  [[ditto? &tpl=`my_news` &parents=`25`]]

                  I got the result
                  &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.


                  I have to say that i created the chunk with the code copied from ditto itself that is:
                  <div class="ditto_item" id="ditto_item_[[+id]]">
                  
                          <h3 class="ditto_pageTitle"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h3>
                  
                          <div class="ditto_documentInfo">by <strong>[[+author]]</strong> on [[+date]]</div>
                  
                          <div class="ditto_introText">[[+introtext]]</div>
                  
                      </div>


                  I hope someone will help me to find a solution or, alternatively, to suggest me another snippet or extra instead of ditto.

                  Thansk all
                    • 22915
                    • 33 Posts
                    What did you name your chunk?
                      • 28215
                      • 4,149 Posts
                      Use getResources and getPage:

                      [[!getPage? 
                         &elementClass=`modSnippet`
                         &element=`getResources`
                      
                         &parents=`11`
                         &depth=`2`
                         &limit=`10`
                         &pageVarKey=`page`
                      
                         &sortby=`publishedon`
                         &sortdir=`DESC`
                      
                         &includeTVs=`1`
                         &includeContent=`1`
                      
                         &tpl=`myNews`
                      ]]
                      <div class="paging">
                      <ul class="pageList">
                        [[!+page.nav]]
                      </ul>
                      </div>
                      


                      with the chunk "myNews":

                      <div class="item" id="item_[[+id]]">
                              <h3 class="pagetitle"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h3>
                              <div class="document_info">by <strong>[[+createdby:userinfo=`username`]]</strong> on [[+publishedon:strtotime:date=`%b %e, %Y`]]</div>
                      
                              <div class="introtext">[[+introtext:default=`[[+content:ellipsis=`100`]]`]]</div>
                      </div>
                      
                        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com