-
- 3,250 Posts
The major limitation in sorting by a user defined date until this point has been that MODx does not store date TV’s in UNIXTIME (it stores them in MySQL Timestamps). I found a simple and clever workaround that maintains backawards compatibility. Just create a widget that takes whatever value in the database (can even be a text field), and turn it into a UNIXTIME stamp that Ditto can use to sort. You now have the ability to enter dates both in text format or using the date chooser. The UNIXTIME Widget has been included in MODx 0.9.5 and later. Then, just append &sortBy=`tvnameofyourtemplatevariable` to your Ditto call and you are done!
-
- 518 Posts
Thanks for your work Mark! But unfortunately this only make a UNIXTIME output for a tv, still Ditto isn’t sorting by it
Look what I have:
the call
[!Ditto? &startID=`17` &sortBy=`tvdate` &sortDir=`ASC` &tpl=`ditto_works` &summarize=`5`!]
output with data formatter widget:
Веб-сайт компании «Венте» («Ватель-Фестен») (Tuesday 27, December 2005)
Веб-сайт компании «Примавель» (Thursday 30, March 2006)
Веб-сайт компании «Astelcom» (Wednesday 15, March 2006)
Дизайн веб-сайта компании «FastHelix» (Monday 28, November 2005)
and output with the unixtime widget:
Веб-сайт компании «Венте» («Ватель-Фестен») (1135640114)
Веб-сайт компании «Примавель» (1143671995)
Веб-сайт компании «Astelcom» (1142379790)
Дизайн веб-сайта компании «FastHelix» (1133134700)
the order keeps the same - by createdon.
-
- 3,250 Posts
And you are using Ditto 1.0.2 right?
-
- 2 Posts
Hi Mark
I tried your solution but alas it still is ordered by ID, it returns a timestamp like this (1060235247) - I also tried protocol0’s hack - the debug mode had listed it as (sortBy): pub_date, when I set it to pub_date - but it didn’t actually follow the order properly.
Has anyone else found a way of sorting the Ditto list or have I missed something
I have missed something - I didn’t format the date correctly - I used the calendar module and it all worked fine!
Thanks
by
-
- 33 Posts
Hmm. Well, I haven’t tried any of the hacks above, but the reason for that is that (besides not knowing how to add a widget) shifting the date widget to a unix time means that I’ll be trading a sorting problem for a display problem. I need my dates displaying in a "November 08, 2006" format at the same time as sorting on that date.
Is there a way to do this?
-
- 433 Posts
I too would like to sort my news by publish date, I am not sure what a widget is in relation to modx, could you help us out here.
Thanks
Lee
-
- 3,250 Posts
@mediced
Use a snippet like DateFormat
@lw-d
A widget is used to format the output of a tv
-
- 129 Posts
Good morning Modx users,
Modx-0.9.5, Ditto 2.0.0, Reflect 1.0.0
I have a weekly newsletter that gets sent out. The menu/page of Biz Flash looks like this with multiple ditto calls:
Biz Flash page (2)
[!Ditto? &startID=`3` &tpl=`DittoTemplate`!]
Apples (3)
News1 (6)
News2 (7)
[!Ditto? &startID=`4` &tpl=`DittoTemplate`!]
Oranges (4)
News1 (8 )
News2 (9)
[!Ditto? &startID=`5` &tpl=`DittoTemplate`!]
Bananas (5)
News1 (10)
News2 (11)
Etc….
The newsletter gets sent out every Friday so the goal is to keep the news from Friday-Friday showing on this page. Stories from the previous week and before would be stored in archives by reflect.
I’m wondering if there’s a solution that can be found by using the date filter, TVs, &sortby=published_on in last 7 days, or something along those lines…
Anyone have a suggestion? Imagine there are a few people that may have come across this situation.
Have a good day, and thanks in advance
Derek