2017-09-24, 05:00

Feb 27, 2012 — Notify Users module, ver. 0.5 released — user can choose between sending single message (...) »

2013-01-28, 08:32

19 студзеня 2013 у Гродне трагічна загінуў паэт, журналіст і мой сябар (...) »

2009-10-14, 07:19

The site Litaratura.org is devoted to Belarusian literary works and translations. (...) »

2009-01-12, 20:46

Late November 2008 marked the 20th anniversary of the official founding of the Belarusian (...) »

Registered User Area Log into This Site
Show Credits... Credits
Worthwhile Services
Refresh My Local Time (GMT+1)... Sep 24, 2017 — 05:00
  • China (1)
    United States (1)
  • Today (59)
  • Yesterday (207)
~ / Public Domain Software / Extensions to Ditto / MostCommented Snippet $_
MostCommented Snippet
Click To View A Full Size Image...
2010-01-10, 15:09

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

Download This Attachment... MostCommented Snippet — the very latest version
Last modified: 2009-09-29, 00:00 — Size: 3,24 KB — Users: 305 — Downloads: 525
Click to show a form...Click to hide the form... Write a comment
  • Required fields are marked with *.
  • Comments are published after the approval of the site owner, who is a human rather than a wind-fast computer program so please be patient.

* Code:
 
Get another image...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...
name111
Comment
Re: MostCommented Snippet
Comment #1 on: 2010-09-21, 15:40
This is not work with ditto splitpagination
dinpapa
Comment
Small Fix
Comment #2 on: 2013-09-07, 19:52
Hi, in some servers the code in line 72:

if (($result = mysql_query($query))

causes some erros. Does it have anything to do that something needs to be escaped before mysql_query($query) is executed?

In my local installation (xampp) it works fine but in my remote server it doesn't even let me save the snippet in the manager.

modx: evo 1.0.6
Apache version: 2.2.3
PHP version: 5.3.14
MySQL version: 5.5.28
Aleksander Maksymiuk
Comment
Re: Small Fix
Comment #3 on: 2013-09-09, 09:00
Most likely the reason of errors you have mentioned should be investigated within PHP settings of your remote (production) host.

This snippet has been written several years ago and from that time PHP itself evoluted much -- for example, ver. 5.3 introduced E_DEPRECATED error level. If this option is set on your remote host, it is possible that mysql_query is regarded as deprecated function thus throwing some errors...