Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-01 07:56:06

SlyShy
New Member
Registered: 2009-03-01
Posts: 2

[request] A Different Kind of Recent Comments Plugin

Hey everyone,

I’d like to request a Recent Comments plugin that is based on a time range, rather than a numeric number of comments. I’d like to be able to display something like:

7 new comments today.

on my site. This seems possible on paper, but I’m not skilled enough to go about it. Thank you in advance.

Offline

#2 2009-03-01 08:57:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: [request] A Different Kind of Recent Comments Plugin

SlyShy wrote:

7 new comments today.

An interesting proposition. I can’t find a way to do it yet, even with the wealth of comment plugins. The closest was asv_recent_comments and I think with a couple of new options (start / end maybe?) could be made to do what you want. But it needs updating to work with TXP 4.0.8 first. Not sure if amit is up for this.

Alternatively, I thought maybe smd_query could do it, but it’s not easy. Assuming you can’t comment on future articles I figured this construct might help:

<txp:smd_query table="txp_discuss" column="discussid,parentid" where='posted > CURDATE() AND parentid="<txp:article_id />"'>
   <txp:smd_if field="1" operator="eq" value="{smd_thisrow}">
      <!-- Display today's count -->
      <p>New comments today: {smd_rows} </p>
   </txp:smd_if>

   <!-- Now display only the comments from today -->

</txp:smd_query>

The first bit works fine. The trouble is the Now display only the comments from today part. If you use <txp:comments /> or any current comment plugin, you see all comments. If you try and put smd_if inside your comment form to filter the list, it fails because the variable that it needs to check (discussid) is not available to the plugin — in fact TXP does not ‘publish’ the comment id to the page at all. asv_recent_comments does do this, but smd_if can’t pick up on it. I could make smd_if do so but that’s still not a clean solution because you are essentially pulling out all comments for every comment and only displaying one each time, which is very very inefficient.

What you really need is one of two things:

  1. a comments tag that can take an ID (or preferably a list of IDs) and only show those comments. Then you can embed that inside smd_query and only show the specific comments from today
  2. a comment plugin that can restrict the list of comments to a date/time range

Not sure if anyone is up for the challenge of either. Maybe one of the existing comment plugin authors (asv, gocom, et al) can help by either modding their plugins are offering a new one?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2009-03-01 20:10:31

SlyShy
New Member
Registered: 2009-03-01
Posts: 2

Re: [request] A Different Kind of Recent Comments Plugin

Thanks a lot for your help. It’s actually just fine that I only get the recent comment count, and not the actual comments, because from there I can link my visitors to a list of all recent comments. The speedy reply was really appreciated.

Offline

Board footer

Powered by FluxBB