Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-05-31 05:25:47

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

wet_recent_comments: Context sensitive recent comments list

wet_recent_comments is a plugin which lists recent comments, both per article and site wide.

It is a single tag which lists a limited amount of the most recent comments, optionally including the comment message.

Distinctive feature: Context sensitivity. When wet_recent_comments is used in a page template, comments are taken from all articles, while in an article form comments are specifically chosen from the ones concerning the current article.

Options include:

  • Limit word count in comment message
  • Strip HTML from comment message
  • Plus the common attributes wraptag, break, class, and labeltag

Usage

<txp:wet_recent_comments />
  • Display the ten most recent comments in the format < cite>Commenter's name</cite > (article title).
<txp:wet_recent_comments limit="5" showcomment="yes" maxwords="25" striptags="yes" />
  • Display the five most recent comments in the format < cite>Commenter's name</cite > (article title)<p >comment message</p >.
  • Limit comment message to a maximum of 25 words plus a trailing ellipsis when appropriate.
  • Strip all HTML tags from the message.

Credits

wet_recent_comments is based on rei_recent_comments, a plugin by Reinier Ladan.

Offline

#2 2006-05-31 10:50:45

ricetxp
Member
From: London, UK
Registered: 2005-05-24
Posts: 89
Website

Re: wet_recent_comments: Context sensitive recent comments list

Using it already. Works very well. Thanks very much

Offline

#3 2006-06-08 17:00:53

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_recent_comments: Context sensitive recent comments list

v0.3, obeys comments moderation status (visibility).

Offline

#4 2006-06-16 17:09:15

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: wet_recent_comments: Context sensitive recent comments list

Hi Robert, I just installed your plugin and it’s working fine, thank you.

I managed to modify the code a little bit (sorry for that) to get it to display it how I like it (got rid of the p tags around the message and have the name and article title after the message). So far so good. But there is one thing I don’t know how to do: I’d like to display the date as well, and I figured out where and how to add $posted to the code, but it’s giving me something like 2006-06-16 12:30:45, which I don’t want, and I don’t know how to format that.

Of course, having ‘showdate’ and ‘dateformat’ attributes would solve my problem as well… ;)

Offline

#5 2006-06-16 17:20:40

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_recent_comments: Context sensitive recent comments list

Els wrote:

Of course, having ‘showdate’ and ‘dateformat’ attributes would solve my problem as well… ;)

I’ll give you just dateformat, which would act as both a switch (display date when set) and a format string (taken from PHP’s strftime()). How’s about that?

Offline

#6 2006-06-16 19:28:51

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: wet_recent_comments: Context sensitive recent comments list

That would be great of course! But I can hardly ask you to go through the trouble if I’m the only one who wants it…

Offline

#7 2006-06-16 19:40:11

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_recent_comments: Context sensitive recent comments list

What matters even more is: Where and how should the date be echoed? The current markup contains the commenters name inside a <cite> element which allows for some styling.

I am considering to enclose the date inside a <span> tag though it leaves enough to be desired. As long as the output is not defined by a form, there’s always room for individualism which has to be satisfied by directly modifying the plugin-in’s code.

So I think I will go that route: Add a generic date output with strftime capabilities after the commenter’s name and leave the rest up to the users PHP capabilities if modifications are desired:

<a href="link-to-comment"><cite>John Doe</cite></a><span>on June 16, 2006</span>
<p>Lorem Ipsum dolor sit ament</p>

What do you think?

Offline

#8 2006-06-16 19:49:01

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: wet_recent_comments: Context sensitive recent comments list

I think that would be perfect :)

Offline

#9 2006-06-16 22:36:33

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_recent_comments: Context sensitive recent comments list

v0.4 introduces a dateformat attribute, which offers various ways of displaying a comment’s posting date:

  1. dateformat is empty: no display.
  2. dateformat is a string containing the word “default”: display the literal string after replacing “default” with the comment posting date formatted according to comment date preferences setting.
  3. dateformat uses conversion specifiers per strftime documentation.

Mix and match of methods 2 and 3 allowed. More samples of various attribute permutations…

Last edited by wet (2006-06-16 22:37:21)

Offline

#10 2006-06-16 23:25:19

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: wet_recent_comments: Context sensitive recent comments list

Thank you, thank you! I really appreciate this. I moved the output around a bit, the result is here (right column, see “Laatste reaktie”). It’s not much (just one recent comment) but exactly as I wanted it.

Thanks again, also for the real quick response.

:)

Offline

#11 2006-09-29 16:33:54

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: wet_recent_comments: Context sensitive recent comments list

Robert,
hey, could you please become my personal plugin slave indentured servant?
I feel like there’s no end to the ideas?

Can you tell me if this is just a rediculous approach to this problem?
I am hoping to achieve this:

<txp:wet_recent_comments 
break=""
wraptag="li"
class="rc<txp:zem_nth step=2 of=2>alt</txp:zem_nth>"
limit="3" 
showcomment="yes" 
maxwords="10" 
striptags="yes" 
dateformat="default" />

So that I can achieve zebra striping on the list.

This is my rediculous attempt to create the gordian knot :
<code>
$a = zem_nth (array( ‘step’ => ’2 0f=2’ ‘value’ => ‘alt’
));
wet_recent_comments (array( ‘class’ => $a, ‘wraptag’ => ‘’ ‘break’ => ‘’ ‘showcomment’ => ‘yes’ ‘maxwords’ => ‘10’ ‘striptags’ => ‘yes’ ‘dateformat’ => ‘default’
));
</code>

Would that cause a nucular (Bush Spelling) meltdown?


Offline

#12 2006-09-29 18:28:49

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_recent_comments: Context sensitive recent comments list

Matthew,

You’re getting quite professional at this.

Minor amends:

echo wet_recent_comments (array( 'class' => $a, 'wraptag' => '', 
'break' => '', 'showcomment' => 'yes', 'maxwords' => '10', 
'striptags' => 'yes', 'dateformat' => 'default'));

echo prints the outcome of the plugin onto the page, otherwise it is silently discarded and adds to the global warming. Array members ('foo' => 'bar') must be separated with commas. And never forget to have your paratheses in balance and your spell-cheker in working order (I didn’t check that, as this wasn’t part of my slavery conslutancy contract).

Last edited by wet (2006-09-29 18:29:27)

Offline

Board footer

Powered by FluxBB