Hi all,
I’ve been fighting with a very strange problem trying to get Ditto to list and sort articles.
Each article has a TV called ’timeStamp’ which is a way for the client to manually control the displayed date for each article. The TV type is Date and it is assigned to the article template.
Here’s the code to display the latest articles:
[!Ditto?&id=`articles` parents=`58` &depth=`0` &dateSource=`timeStamp` &sortBy=`timeStamp` &tpl=`inprint_tpl` &summarize=`6` &paginate=`1` &display=`6` &hideFolders=`1` !]
<p>Showing <strong>[+articles_start+]</strong> - <strong>[+articles_stop+]</strong> of <strong>[+articles_total+]</strong> Articles
<div id="ditto_pages">Pages: [+articles_previous+] [+articles_pages+] [+articles_next+] </div>
Here’s the inprint_tpl template chunk:
<div class="inprint_ditto">
<p><a class="inprint_title" href="[~[+id+]~]" title="[+title+]">[+title+]</a> <span class="ditto_info" >[+date+] </span>
[+introtext+]</p>
</div>
All articles have their timeStamp value set by using the MODx date picker widget. I confirmed that the values are saved in the modx_site_tmplvar_contentvlaues table.
But for some reason instead of the actual values of the TV each article displays the same date of "January 1 1970, 07:00", which makes be think that Ditto cannot find the actual date value. Another strange thing is that in the database the type of the TV value field is ’string’ and not ’date/time’ as i would have expected.
Does anybody have any insight into how to make Ditto use a TV instead of built-in dates?
Thanks in advance.
hmm.... should work this way normally
perhaps it is a similar problem like this:
http://modxcms.com/forums/index.php?topic=26619.0
btw: there is a missing & at parents=`58` -> &parents=`58` ,but I don’t think it has to do with your problem
Thanks a lot Bruno17,
i read through this thread and did find the solution to the first problem.
Setting the TV’s widget to Unixtime solved it. The Ditto snippet now shows the correct dates and sorts them properly.
Unfortunately the related Reflect call is now showing January 1970.
Here’s the Reflect Call:
[!Reflect?config=`wordpress` &id=`archive` &dateSource=`timeStamp` &dateFormat=`%c` &targetID=`85` &showItems=`0` &dittoSnippetParameters=`startID:58|dateSource:timeStamp` groupByYears=`1` groupByMonth=`0` &getDocuments=`1`!]
Here’s the target Ditto call in document 85:
<h2>Archive [+archive_month+] [+archive_year+]</h2>
[!Ditto?id=`archive` &parents=`58` &depth=`2` &hideFolders=`1` &extenders=`dateFilter` &dateSource=`timeStamp` &dateFormat=`%c` &tpl=`inprint_tpl` &sortBy=`timeStamp` &paginate=`1` &display=`6` !]
<p>Showing <strong>[+archive_start+]</strong> - <strong>[+archive_stop+]</strong> of <strong>[+archive_total+]</strong> Articles
<div id="ditto_pages">Pages: [+archive_previous+] [+archive_pages+] [+archive_next+] </div>
So it seems that the date in the db is stored correctly but Ditto and Reflect are having difficulties reading it.
I’m using MODx version 0.9.6.2