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.
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...
- 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)
- at which symbol the comment should be truncated (default: 0, do not truncate)
- symbol/string to use for marking truncation (default: ’...’)
[!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="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:
Please notice that placeholders for Jot custom fields SHOULD BE prefixed with "jcf_"
Both [+uparent+] and [+doc_id+] stand for the same value