In certain circumstances you might like to be able to show comments from a certain weblog anywhere on your site. For instance you might like to show all comments sorted by the person who commented on a separate page.
As this isn’t possible using the standard comment entries tag as its intended use is for on single entry type pages where the comment entries tag will receive the information it requires from the URL in order to pull in the correct comments then the easiest way to do this is with a SQL query as shown below.
{exp:query sql="
SELECT ec.comment_date, ec.comment_id, ec.entry_id, ec.author_id, ec.name, ec.email, ec.url, ec.location, ec.comment, em.username
FROM exp_comments ec
LEFT JOIN exp_members em
ON ec.author_id = em.member_id
WHERE ec.weblog_id = '1'
ORDER BY ec.author_id
"}
<p>{comment} - posted by {username}</p>
{/exp:query}
This should give you access to the following variables :
{comment_id}
{entry_id}
{author_id}
{name}
{email}
{url}
{location}
{comment}
{username}
{comment_date format=”%d %m %Y”}Note that not all of these may have been filled in by the person commenting so may indeed be empty.
