Mark (NewsListing’s author) will be able to give a great example of that very soon. In the meantime, here’s our main blog page content:
<?php
<div id="nl_wrapper">
[[nl? &startID=`254` &tpl=`nl_blog_tpl` &summarize=`5` &commentschunk=`FormBlogComments` &paginate=`1` &dateformat=`%d-%b-%y` &alwaysshow=`1` &truncText=`Read more...` &multilevel=`1` &filter=`hidemenu, 0|parent, 254,2`]]
</div>
<div class="nl_paging">Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles<br />
<div id="nl_pages"> [+previous+] [+pages+] [+next+] </div>
<!-- close .nl_paging -->
<a href="[~274~]?id=[*id*]" style="border-bottom: medium none; float: right; margin-right: -1em; margin-top: -25px;"><img border="0" src="http://modxcms.com/assets/images/greenzi/icons/rss.jpg" alt="RSS feed icon" /> </a>
</div>
?>
Here’s our Newslisting Template:
<?php
<div class="nl_article">
<h3 class="nl_title">
<span class="nl_info"> <strong><a href="[~[+parent+]~]">[+author+]</a></strong> on [+date+]</span><a href="[~[+id+]~]">[+title+]</a>
</h3>
[+summary+]
<p class="nl_link"><a href="[~[+id+]~]#comments">Comments ([!UserCommentsCount?docid=[+id+]!])</a> | [+link+]</p>
</div>
?>
Here’s our comments chunk template:
<?php
<a name="comments" id="comments"></a>
<p class="BlogMeta">
<strong>Meta: </strong><a href="[~274~]?id=[*parent*]"> <img src="assets/images/greenzi/icons/blog-feed.jpg" alt="RSS feed" /> </a> <a href="[(site_url)]index.php?id=[*id*]"> <img src="assets/images/greenzi/icons/blog-permalink.jpg" alt="Permalink" /> </a>
</p>
<p><strong>Comments: </strong></p>
<div>
[!SMF_UserComments? &makefolder=`1` &formtpl=`commentForm` &sortorder=`0` &freeform=`1` &displaytpl=`comment` &postcss=`comment` &titlecss=`commentTitle` &numbercss=`commentNum` &altrowcss=`commentAlt` &authorcss=`commentAuthor` &ownercss=`commentMe` &dateformat=`%d-%b-%y %I:%M %p` !]
</div><br />
[+UserComments.Form+]
?>
And our UserCommentsCount snippet:
// Comment count by Mark Kaplan
$docid = isset($docid) ? $docid : $modx->documentObject['id'];
// get folder id where we should store comments
// else store in current document
$folder = isset($folder) ? intval($folder):$docid;
// set splitter
$splitter = '<!--Comment-Spliter:'.$docid.'-->';
// get tagid
$tagid = isset($tagid) ? preg_replace("/[^A-z0-9_\-]/",'',$tagid):'';
// set alias name of document used to store comments
$alias = 'usrcmt-'.$docid.($tagid ? '-'.$tagid:'');
// get comments
$ds = $modx->db->select('content',$modx->getFullTableName('site_content'),' parent=\''.$folder.'\' AND alias=\''.$alias.'\'');
$content = $modx->db->getValue($ds);
// split content into separate comments
$parts = explode($splitter,$content);
array_pop($parts);
// count comments
$count = count($parts);
return $count;
?>
Sorry for the long post but I hope it proves to be insightful. Lots of changes and tweaks will be happening to the above soon I suspect, too.