Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
, andlabeltag
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
Re: wet_recent_comments: Context sensitive recent comments list
Using it already. Works very well. Thanks very much
Offline
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
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
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
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:
dateformat
is empty: no display.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.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
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?
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
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