June 05, 2004

"Latest Comments" Code?

I dig that Latest Comments feature on the sidebar here. Is there code available for adding that to our blogs? For one site specifically, I mean.

Seems to be a great way to let readers know where the comment activity is, without scanning every post.

Posted by Ace at June 5, 2004 02:02 AM
Comments
#1

There are several threads concerning recent comments over at the MT Support Forum.

Try this code:
<MTSetVar name="Counter" value="0">
<MTGlobalComments sort_order="descend">
<MTIfLess a="[MTGetVar name='Counter']" b="5" numeric="1">
<MTIfNotEqual a="[MTCommentAuthor]" b="Lisa">
• <MTCommentAuthorLink spam_protect="1">:
<MTCommentEntry>
<a href="">[...]
</MTCommentEntry>

<MTIfEqual a="[MTGetVar name='Counter']" b="4" numeric="1">
<MTSetVar name="Counter" value="5">
</MTIfEqual>
<MTIfEqual a="[MTGetVar name='Counter']" b="3" numeric="1">
<MTSetVar name="Counter" value="4">
</MTIfEqual>
<MTIfEqual a="[MTGetVar name='Counter']" b="2" numeric="1">
<MTSetVar name="Counter" value="3">
</MTIfEqual>
<MTIfEqual a="[MTGetVar name='Counter']" b="1" numeric="1">
<MTSetVar name="Counter" value="2">
</MTIfEqual>
<MTIfEqual a="[MTGetVar name='Counter']" b="0" numeric="1">
<MTSetVar name="Counter" value="1">
</MTIfEqual>

</MTIfNotEqual>
</MTIfLess>
</MTGlobalComments>

from this thread. Replace "Lisa" in line #4 with whatever your name is and it will give the last 5 comments that were made by people other than you. If you want to display more than 5 comments, just look at the code and modify where appropriate.

Posted by Madfish Willie at June 5, 2004 03:50 AM
#2

Here is the code that dipslays recent comments on this page:

<div class="side">
<MTComments lastn="10" sort_order="descend">
<$MTCommentAuthorLink show_email="0"$>: <$MTCommentBody convert_breaks="0" trim_to="60" remove_html="1"$>
<MTCommentEntry>
<a href=""><i>entry</i></a>
</MTCommentEntry><br />
</MTComments>
</div>

Posted by Madfish Willie at June 5, 2004 05:38 AM
#3

Thanks. The second bit of code works.

I didn't try the first bit. I wasn't sure if that bold-bullet in the first paragraph was supposed to be there or is just an error.

Also, I didn't know if the bit three lines after that, containing this:

[...]

was realy supposed to be coded that way, of if there's something I'm suppsed to substitute in for the [...} .

Is there a big difference between the two?

Either way, thanks. Like I said, the second one works great.

Posted by ace at June 6, 2004 09:48 PM
#4

Actually, I spoke too soon. The second code displays the latest posts, but the "entry" link doesn't link to the comment; it just links right to the main page.

Posted by ace at June 6, 2004 09:52 PM
#5

The first code, at least for me, gives an error on rebuild. It tells me that I used a "commentauthor" entry outside of a comment, and then it suggested that perhaps I'd mistakenly used it outside an MTCommententry "container."

Posted by ace at June 6, 2004 10:02 PM
#6

The first one, follow the link back to the discussion thread. The rest of the thread should tell you something about if it works and what the problems were implementing it. The bullet was supposed to be there. I didn't test it, so I don't know how/if it works.

The second one should read:

<a href="<$MTEntryLink$>"><i>entry</i></a>

I missed converting the tags and it got parsed.

Posted by Madfish Willie at June 6, 2004 10:55 PM
Live Comment Preview
Post a comment









Remember personal info?