Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-11-13 03:07:04

Chalito
Plugin Author
Registered: 2007-08-22
Posts: 26

[ORPHAN] cha_comment_reply

Hi Folks!

I’ve just posted my comment reply plugin here, and you may get the uncompiled php file here.

In a nutshell, it creates a new table to keep comments related, and provides a set of tags for displaying the comments with different classes depending on wether they’re comments to the article, or comments in reply to other comments. Also there’s a tag for adding a select widget to the comment post form, which makes replying possible.

here’s part of the contents of the help section (I think it’ll give a better idea of how it works):

2) The Tags

This plugin provides the following tags:
  • <txp:cha_reply_lbl> prints a label with a link to the comment post form and sets the reply_to value to the comment the label was clicked from. The attributes accepted are:
    • label: Text of the label/link.
  • <txp:cha_indenting_div> This wrapping tag will enclose a comment in a <div> block with a class that will vary depending on the comment being either a reply to the article or to another comment. Attributes accepted:
    • class: the base name of the class for the div block. Direct replies to the article will have this as a class, replies to other comments will have ‘indented_’ prepended to this as class name.
  • <txp:cha_indented_comments> Replaces the built-in <txp:comments> tag, and works with cha_indenting_div to produce indenting class for comments.
  • <txp:cha_reply_to> Prints a drop-down ‘select’ widget that reacts to set the item the user is replying to (default: reply to the article, changes to a comment ID if the user clicks on the reply link of a comment set by the cha_reply_lbl tag). This is supposed to go in the comment data entry form.

3) The Table

This plugin will check for the existence of a table named ‘cha_txp_discuss_rel’ in the textpattern database, and will create it if it doesn’t exist. This table will contain association data for comments using two columns: one for the id of the comment being saved, and another for the id of the parent comment being replied to.

4) Examples

This is an example of how to implement this plugin into a default installation of Textpattern. You only need to put the right tags in a few forms:

In the form ‘comments_display’:

<h3 id="<txp:text item="comment" />"><txp:comments_invite textonly="1" showalways="1" showcount="0" /></h3>

<txp:cha_indented_comments wraptag="" break="p"/>

<txp:if_comments_preview>
<div id="cpreview">
<txp:comments_preview />
</div>
</txp:if_comments_preview>

<txp:if_comments_allowed>
<txp:comments_form />
<txp:else />
<p><txp:text item="comments_closed" /></p>
</txp:if_comments_allowed>

In the form ‘comments’:

<txp:cha_indenting_div class="comment">
<txp:comment_message />

<p class="small">— <txp:comment_id/>  — <txp:comment_name /> · <txp:comment_time /> · <txp:comment_permlink>#</txp:comment_permlink>·
<txp:cha_reply_lbl />
</p>
</txp:cha_indenting_div>

And in the form ‘comment_form’:

<txp:comments_error wraptag="ul" break="li" />

<table cellpadding="4" cellspacing="0" border="0">

<tr>
        <td align="right">
                <label for="reply">Replying To:</label>
        </td>
        <td>
           <txp:cha_reply_to />
        </td>
</tr>
(...)

Then remember to define some CSS class to handle indentation, like so:

div.indented_comment {
position: relative;
left: 20px;
}

This should get you Nested comments and the ability to reply to other comments.

Apart from this, there is an admin tab for deleting orphaned relationships. When you delete a comment that has replies, these replies stay in the db, but because their parent comment is never looked for in the tree, they never show up. So with this admin tool you can check if there are any comment relationships whose parent comment does not exist anymore, and delete them. That way the orphaned comments will be displayed as replies to the article directly. It’s not too pretty, but I wanted to get something out that was simple. Might try to do something better with that in a future version.

Cheers,

Chalito

Last edited by Chalito (2007-11-14 21:09:49)

Offline

#2 2007-11-13 20:24:02

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: [ORPHAN] cha_comment_reply

Looks great. Any example site we can see?

Offline

#3 2007-11-13 21:11:29

Chalito
Plugin Author
Registered: 2007-08-22
Posts: 26

Re: [ORPHAN] cha_comment_reply

You can try mine, it’s awful, as I’ve just set it up to hold a couple of personal-use links and test the plugin.
Post as much as you like in it. (It’s VERY slow, as it’s on my cable connection with pity upstream bandwidth, and bittorrent isn’t helping either hehe but I think it should be enough for testing).

Hangar18

Offline

#4 2007-11-17 13:28:58

M_i
Member
Registered: 2006-03-05
Posts: 122

Re: [ORPHAN] cha_comment_reply

It’d be nice if commenters could receive email notification if someone replied on their comment — just like authors can receive an email when someone comments on their article.

Offline

#5 2007-11-18 01:58:55

Chalito
Plugin Author
Registered: 2007-08-22
Posts: 26

Re: [ORPHAN] cha_comment_reply

Good idea, I’ll try adding it to the next version :)

Offline

#6 2007-11-20 14:25:32

baby
Plugin Author
From: Buenos Aires, Argentina
Registered: 2005-10-16
Posts: 95
Website

Re: [ORPHAN] cha_comment_reply

M_i, Chalito… watch out, since this is a two-edged sword… the email addresses of the people who post comments, unlike those of article authors, is by no means verified to exist, much less to be within the control of the person who posted the comment…

Adding this kind of notification opens a port for abuse… I could post a hundred comments using your email address (or even replying to a post you made) and flood your inbox without your control… the final culprit (the one with the account closed) is the owner of the textpattern site…


Mariano AbsatzEl Baby

I don’t suffer from insanity. I enjoy every minute of it.

Offline

#7 2007-11-20 17:09:00

Chalito
Plugin Author
Registered: 2007-08-22
Posts: 26

Re: [ORPHAN] cha_comment_reply

Yeah, after I replied, i started thinking that too.. so i thought maybe it could be an option so whoever wants to use it can enable at their own risk, but it doesn’t make that much sense. Maybe if the user was somehow registered it could work.

Offline

#8 2007-11-21 11:49:29

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: [ORPHAN] cha_comment_reply

Hi Chalito,
I have a problem with the plugin: the comments are indented in any case (direct replies to articles as well as replies to another comment).
Surely I did some stupid error but can’t find it.
I just followed your instructions pasting your example code in the appropriate forms but , as I said, every comment is enclosed in a “indented_comment” class.
Any help is appreciated. thanks in advance

Offline

#9 2007-11-21 12:55:46

baby
Plugin Author
From: Buenos Aires, Argentina
Registered: 2005-10-16
Posts: 95
Website

Re: [ORPHAN] cha_comment_reply

do you have an example on line so I can see the html/css source?
maybe some css class got misplaced in your forms


Mariano AbsatzEl Baby

I don’t suffer from insanity. I enjoy every minute of it.

Offline

#10 2007-11-21 13:46:20

Chalito
Plugin Author
Registered: 2007-08-22
Posts: 26

Re: [ORPHAN] cha_comment_reply

Hm sounds weird, the div is what gets an indented_ class.. and it should only get that if there’s a reference to it in the relations table. did you check the table? can you paste the modifications you made? (especially the ones to the forms)

Offline

#11 2007-11-21 14:25:18

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: [ORPHAN] cha_comment_reply

Mariano and Chalito,
thanks for your fast replies.
I repeat I’m sure it depends from a stupid error I made somewhere.
Anyway you can have a look at the test page I’ve prepared here . As you can see every comment is given a class “indented_comment” even if the first one is a reply to the article itself and the second comment is a reply to the first comment.
Here are the forms I’m using (I’m using if_section because I need nested comments only in this section)

“comments” form


<txp:if_section name="bridge-to-europe">
<txp:cha_indenting_div class="comment">
<txp:comment_message />
<p class="small">— <txp:comment_id />  — <txp:comment_name /> · <txp:comment_time /> · <txp:comment_permlink>#</txp:comment_permlink>·
<txp:cha_reply_lbl />
</p>
</txp:cha_indenting_div>
<txp:else />
<div class="comment">
<txp:comment_message /><br />
<small>— <txp:comment_name />    <txp:comment_time />    <txp:comment_permlink>#</txp:comment_permlink></small>
</div>
</txp:if_section>

“comment_display” form


<txp:if_section name ="bridge-to-europe">
<h3 id="<txp:text item="comment" />"><txp:comments_invite textonly="1" showalways="1" showcount="0" /></h3>
<txp:cha_indented_comments wraptag="" break="p" />
<txp:if_comments_preview>
<div id="cpreview">
<txp:comments_preview />
</div>
</txp:if_comments_preview>
<txp:if_comments_allowed>
<txp:comments_form />
<txp:else />
<p><txp:text item="comments_closed" /></p>
</txp:if_comments_allowed>
<txp:else />
<h3 id="<txp:text item="comment" />"><txp:comments_invite textonly="1" showalways="1" showcount="0" /></h3>
<txp:comments />
<txp:if_comments_preview>
<div id="cpreview">
<txp:comments_preview />
</div>
</txp:if_comments_preview>
<txp:if_comments_allowed>
<txp:comments_form />
<txp:else />
<p><txp:text item="comments_closed" /></p>
</txp:if_comments_allowed>
</txp:if_section>

“comment_display” form


<txp:comments_error wraptag="ul" break="li" />
<table cellpadding="4" cellspacing="0" border="0" class="commentform">
<txp:if_article_section name="bridge-to-europe">
<tr>
<td align="right">
<label for="reply">Replying To:</label>
</td>
<td>
<txp:cha_reply_to />
</td>
</tr>
</txp:if_article_section>
<tr>...... (the remaining part of the form is unchanged)

Offline

#12 2007-11-21 16:19:59

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: [ORPHAN] cha_comment_reply

Don’t know if it can be useful, anyway here is an image from phpmyadmin showing the “cha_txp_discuss_rel” table

as you can see everything seems to be right…

Offline

Board footer

Powered by FluxBB