We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27733
    • 99 Posts
    OK folks: my bad! I had made an alteration to the reflect snippet code that I finally found. It’s actually a reversion of a handful of lines to a pre-modx 1.x version. This is only good for php <= 5.2.x, though, as the way that the func_get_args is used is deprecated in 5.3. Once I get a few more moments, I’ll see if I can untangle and really fix the problem so it’s forward compatible. Anyway, here ’tis:

    Replace 279-287:
    $reflectParameters = array('reflect_base','config','id','getDocuments','showItems','groupByYears','targetID','yearSortDir','monthSortDir','start','phx','tplContainer','tplYear','tplMonth','tplMonthInner','tplItem','save');
        $params =& $modx->event->params;
        if(is_array($params)) {
            foreach ($params as $param=>$value) {
                if (!in_array($param,$reflectParameters) && substr($param,-3) != 'tpl') {
                    $dParams[$param] = $value;
                }
            }
        }
    

    With:
    $allParameters = func_get_args();
    	$reflectParameters = array('reflect_base','config','id','getDocuments','showItems','groupByYears','targetID','yearSortDir','monthSortDir','start','phx','tplContainer','tplYear','tplMonth','tplMonthInner','tplItem','save');
    	foreach ($allParameters[1] as $param=>$value) {
    		if (!in_array($param,$reflectParameters) && substr($param,-3) != 'tpl') {
    			$dParams[$param] = $value;
    		}
    	}
    
      ------
      Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
      • 13373
      • 70 Posts
      I was hoping this would be the magic fix, but alas - it doesn’t work for me (using PHP 4.3.9).

      I did get some dates listing (instead of January 1970), but they were:

      May 2034
      March 2024
      ....
      ....

      etc - just weird dates that I have no idea where it would get those from. It also still showed all documents for each date (when clicking on it), whereas it should only show documents that belong to that month.

      Back to the drawing board?!
        • 27733
        • 99 Posts
        If you would, go ahead and post your ditto & reflect calls and maybe I’ll be able to assist ...
          ------
          Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
          • 13373
          • 70 Posts
          Here’s the Reflect call that’s causing the problems:

          [!Reflect?config=`wordpress` &targetID=`202` &dittoSnippetParameters=`parents:163` &getDocuments=`1` &dateSource=`myDate` &id=`wpjkb` &monthSortDir=`ASC` &tplContainer=`eventContainer`!]

          The issue is the `mydate` datesource - if I change it to createdon etc, it works fine. I’m using a custom date tv for each document, as the events are in the future.

          There’s no problems with the Ditto results.
            • 27733
            • 99 Posts
            A few things:

            As an example, here are my calls (which only require a simple archive by year):
            
            [[Ditto?parents=`101` &id=`articles` &depth=`3` &extenders=`dateFilter` &dateFilterSource=`params` &dateFilterDefault=`1` &sortBy=`articleDate` &dateSource=`articleDate`  &tpl=`articleTpl` &paginate=`1`  &paginateAlwaysShowLinks=`1` &tplPaginatePage=`articleTpl_pages` &tplPaginateCurrentPage=`articleTpl_pages_current` &hideFolders=`1` &display=`12`]]
            
            [[Reflect? &id=`articles` &targetID=`690` &dateSource=`articleDate` &localFilterDelimiter=`:` &filter=`articleDate:0:2|articleDate:@EVAL return mktime(0,0,0,1,1,date("Y"));:5` &dittoSnippetParameters=`parents:101|depth:3` &getDocuments=`1` &tplYearInner=``]]
            
            


            Hope this helps!
              ------
              Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
              • 26277
              • 8 Posts
              Hi Guys,
              It’s looks like it isn’t problem with Ditto or Refelect. I’ve check the database entry and the date is stored correctly. However if you try to bring this date without Ditto or Reflect just inserting tv call into page, the result is not correct. eg. my custom date is 05-07-2010 9:10:00 and that what is stored in db, and the result on the page is 1293786600 (timestamp) and after conversion to date is Fri, 31 Dec 2010 09:10:00 GMT ??
              Can you test custom date field without Ditto or Reflect and let me know if the dates are showing correctly or not?
                • 13373
                • 70 Posts
                I can confirm that this is the case for me also.

                I echoed my myDate tv, and converted the timestamp, and lo and behold, got those weird dates like March 2024 etc.

                I’ve also checked the database, and the stored datestamp is correct.

                So, it looks like something is going very wrong with the conversion of the date from the DB into a unix timestamp!

                That, plus the change that smg6511 made, should clear things up?

                Cheers,
                Jacob
                  • 26277
                  • 8 Posts
                  Guys,
                  I think I’ve figured out correct setup to get this to work. However still don’t know were the problem is.

                  My solution was:

                  1. Set Date format in Configuration to YYYY/mm/dd (that was crucial)
                  2. Create documentDate TV (Input type: Date, widget: Unixtime)

                  My calls are below:

                  Bring all news stories sorted by documentDate:

                  [[Ditto? &extenders=`dateFilter` &debug=`0` &parents=`30` &summarize=`4` &tpl=`newsListTpl` &paginate=`1` &paginateAlwaysShowLinks=`0` &dateFormat=`%y %d` &dateSource=`documentDate` &sortBy=`documentDate` &sortDir=`DESC` ]]

                  Archives call (Ditto + Reflect):

                  [[Reflect? &id=`archive` &dateSource=`documentDate` &dittoSnippetParameters=`parents:30|sortBy:documentDate|hideFolders:1` &groupByYears=`1` &getDocuments=`1` &targetId=`31` &showItems=`0`]]

                  [[Ditto? &id=`archive` &parents=`30` &display=`all` &tpl=`newsListTpl` &paginate=`0` &extenders=`dateFilter` &paginateAlwaysShowLinks=`0` &dateSource=`documentDate` &dateFormat=`%y %d` &sortBy=`documentDate` &sortDir=`DESC`]]

                  Hope this help but still have no clue why default date format in configuration doesn’t work...


                    • 27733
                    • 99 Posts
                    One thing I’d failed to mention above, which may or may not make a difference for you, is that I format my dates via phx (in my ditto tpls) and not via the ditto call (ex.: [+articleDate:date=`%m/%d/%Y`+]).
                      ------
                      Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
                      • 26277
                      • 8 Posts
                      Have the same setup: [+documentDate:date=`%d %B %Y`+]