Some people ask how to call Ditto and sort its results by the number of comments attached. The simpliest answer is that it cannot be done within the means given by Ditto itself. Ditto „realizes” neither Jot’s existence nor the way it handles comments.
This is a task for a new snippet that would correlate Ditto’s result set with a data stored in Jot-handled tables. Just this is a way that my MostCommented snippet operates: 1) runs Ditto in an invisible mode to retrieve document’s ids from the scope being the topic of interest, 2) explores Jot’s table to look/count how many comments are attached to documents within a retrieved scope; 3) sorts documents descendingly by the calculated numbers.
MostCommented snippet recognizes six parameters — parents, depth, display, filter, tpl, and noResults — that have the same meaning as in Ditto call. If you want to use more Ditto-specific parameters you need to look into the snippet’s code and follow the instructions on how to extend it.
MostCommented snippet has been initially posted to this thread on MODx Forum.
How to use MostCommented
# 1) create new snippet 'MostCommented' and paste into it content of the attached mostcommented.txt file
# 2) call your snippet something as:
[[MostCommented? &parents=`2,46` &depth=`1` &display=`5` &filter=`type,document,1` &tpl=`item-chunk` &noResults=`No comments so far.`]]
# 3) please read more details on parameters in snippet's header
- Required fields are marked with *.
- Comments are published after the approval of the site moderator, who is a human rather than a wind-fast computer program so please be patient. Off-topic comments are definitely removed.
| Enter this code into the appropriate field of the form while submitting an e-mail or a comment. If you have trouble with reading it, generate another... |


