I want Ditto to present the content of only the latest of a number of documents. I am able to achieve the desired result, but I don’t like its semantics.
I am currently calling Ditto like this:
[!Ditto?
&id=`homeNews`
&debug=`0`
&parents=`5`
&display=`1`
&showPublishedOnly=`0`
&orderBy=`createdon DESC`
&tpl=`homeNewsTpl`
&paginate=`0`
!]
I dislike this call because it "tricks" Ditto into presenting what I desire. It commands Ditto to present non-paginated results, order the results by descending creation date/time and just present one result, i.e. the latest document.
Sure enough, when I look at the debugging window, I note that Ditto has actually retrieved
every document in order to present just the latest one. This is wasteful and will increase page creation time as the number of documents grows.
I want something straightforward and hopefully more efficient, such as a "&firstDocument" parameter. The converse "&lastDocument" would be useful, too.
(Using Ditto to present the latest document is like swatting a fly with a large hammer. Certainly I could accomplish this directly via SQL. However, I am using Ditto elsewhere in the site anyway, and there is no guarantee that he who eventually supports the site will know about SQL.)
Thanks in advance for your ideas!
-- Halfnium