In several threads around this forum I helped people with rendering latest comments which appeared to be a painful issue.
Recently I have rewritten/generalized the code used for such rendering by adding templating feature, date formats, etc.
Download:
http://setpro.pl/download.php?item=latestcomments.txt
Small article:
http://setpro.pl/software/latest-comments
Some guidelines on how to use this snippet have been included into its header. I am pasting those instructions here...
Parameters:
parents - which container(s) to fetch the comments from (default: 0, entire site)
count - how many latest comments to fetch (optional; default: 6)
customFields - comma-separated list of custom fields (optional; default: name,email)
posterField - poster’s field name (optional; default: name)
dateFormat - PHP’s date() format for createdon, editedon fields (optional; default: Y-m-d, H:i:s)
tplComment - chunk containing template for a single comment (REQUIRED; see example below)
trunc - at which symbol the comment should be truncated (default: 0, do not truncate)
truncSym - symbol/string to use for marking truncation (default: ’...’)
Sample usage:
[!LatestComments? &count=`3` &customFields=`name,website` &tplComment=`tpl-comment`!]
Sample template (chunk tpl-comment):
<div class="poster"><a href="[+jcf_website+]">[+jcf_name+]</a> on [+createdon+] said:</div>
<div class="post">"[+content+]"</div>
<div class="link">Read full article <a href="[~[+doc_id+]~]">[+doc_pagetitle+]</a>...</div>
Comment’s main placeholders:
[+id+] - internal id of the comment
[+title+] - self-explanatory
[+tagid+] - value used to distinguish two (or more) Jot calls on the same page
[+uparent+] - id of the document that the comment is attached to
[+secip+] - IP of the remote machine that the comment has been submitted from
[+content+] - self-explanatory
[+createdby+] - full name of the author (either MODx user or poster-provided value)
[+createdon+] - date of the creation (formatted with dateFormat)
[+editedby+] - full name of the MODx user who latest accessed/changed the comment
[+editedon+] - date for the above action (formatted with dateFormat)
[+publishedby+] - full name of the MODx user who published the comment (if in moderated mode)
[+publishedon+] - date for the above action (formatted with dateFormat)
Comment’s custom placeholders:
[+jcf_...+]
Document’s placeholders:
[+doc_id+]
[+doc_pagetitle+]
[+doc_longtitle+]
[+doc_description+]
[+doc_introtext+]
Important remarks:
Please notice that placeholders for Jot custom fields SHOULD BE prefixed with "jcf_"
Both [+uparent+] and [+doc_id+] stand for the same value