SED Comment Pack Plugin Documentation
SED Comment Pack plugin, v0.3 May 20th, 2006.
New in this version…
- variations to the
sed_comment_numbertag allowing it to count up or down. - integration with a hacked version of
sdr_guestbookworked on by myself and Els.
What happened to v0.2?
I have decided not to release the custom features I implemented for my site in v0.2 of this plugin because of the way they mimic the behaviour of the TXP core comment functionality. I don’t want to have to re-work and support those features for the next release of TXP. Sorry folks!
Summary
I was inspired to put this pack of helper tags together by some of the plugins from Compooter.org. I particularly wanted to improve the situation for detecting author comments in multi-author sites. However, what came out of this exercise has application for every TXP installation with commenting enabled where the author of the article takes an active role in writing comments in reply to what others have said.
The ajw_if_comment_author plugin was my first port of call to try to setup my comment system. It does things pretty well but requires author data to be supplied in the TXP forms—a place where, IMO, author data shouldn’t be appearing as it is difficult to maintain and, whilst it can handle checking against more than one supplied string, this solution does not scale well.
I also found that the conditional tag complicated the logic in the form and wanted to simplify this. So, rather than having a conditional tag that split my TXP comments form into two logical branches, I wanted tags that simply returned the right thing, no matter if an author comment or not. These tags moved the data and processing from the form—simplifying it greatly.
These tags allow me to do that…
<txp:sed_get_comment_class/>tag specifically to calculate the class to apply to a comment block.<txp:sed_if_author_comment_string/>tag to conditionally output a string to mark up any author comments.<txp:sed_comment_number/>tag to output the sequential comment number on the page counting either up or down or paginated for guestbook integration.<txp:sed_comment_time/>tag upgrades the default TXP tag with wraptag and class.
All of them are designed for use in the TXP forms called comments and, if you use it, comments_preview.
In addition, the following tags are also available…
<txp:sed_if_comments/>tag is a replacement for the<txp:if_comments/>tag. It can be put in page templates.
Pre-requisites
Make sure that your site admin preferences are setup to turn off ordered lists.
- Admin > Preferences > Comments: ‘Present comments as a numbered list?’ Set to no.
- Enable this plugin!
- Use the tags in the TXP forms called comments and comments_preview.
Example TXP Forms
| # | Code |
|---|---|
| 0001 | <div class="<txp:sed_get_comment_class />"> |
| 0002 | <txp:comment_anchor /> |
| 0003 | <h5><span class="comment-no"><txp:comment_permlink> #<txp:sed_comment_number/></txp:comment_permlink></span>· <txp:comment_name /><txp:sed_if_author_comment_string string=' (Author Comment)' /></h5> |
| 0004 | <txp:sed_comment_time class='comment-time'/> |
| 0005 | <txp:message /> |
| 0006 | </div> |
| # | Code |
|---|---|
| 0001 | <div class="<txp:sed_get_comment_class hide_odd_even='1' />"> |
| 0002 | <h5><span class="comment-no"><txp:comment_permlink> #</txp:comment_permlink></span>· <txp:comment_name /><txp:sed_if_author_comment_string string=' (Author Comment)' /></h5> |
| 0003 | <txp:sed_comment_time class='comment-time'/> |
| 0004 | <txp:message /> |
| 0005 | </div> |
Tag Directory
<txp:sed_get_comment_class/>
For use in the TXP forms comments and comments_preview, this tag outputs a string for use in the CSS class string of the comment being processed.
This tag can take the following optional attributes…
| Attribute | Default Value | Description |
| ‘class’ | ‘comment’ | Name of the basic class applied to all comments. |
| ‘author_class’ | ‘author’ | Set to an empty string (‘’) to turn off the commentor-is-author checking otherwise enter the name of the class you wish your author comments to be tagged with. |
| ‘odd_class’ | ‘odd’ | The string to use to mark odd numbered comments. |
| ‘even_class’ | ‘even’ | The string for even numbered comments. |
| ‘hide_odd_even’ | ‘’ | Set to any non-empty value to surpress odd/even comment marking. Useful in comment preview form. |
| ‘method’ | ‘check-email’ | Any value other than ‘check-password’ will cause the comment email to be checked against the author’s email. |
The format of the output is “class [odd_class|even_class] [author_class]“
Where the highlighted names are the names of the attributes of the tag.
Everything should work by default to give you one of these possible outputs…
- “comment”
- “comment odd”
- “comment even”
- “comment author”
- “comment odd author”
- “comment even author”
The value of the attribute odd_class is only output on odd numbered comments, even_class on even numbered comments though the odd/even row output can be turned off by setting the attribute ‘hide_odd_even’ to a non-blank value.
The ‘author_class’ value is only output if it is non-blank and the commentator’s details match the article author’s details stored in the internal TXP users table. Note, this can be turned off by setting the attribute ‘author_class’ to a blank value.
If the checking is on then the commentors name will be checked to see if it matches the Real Name of the article author. If it does then the attribute ‘method’ controls how the matching of commentor’s and author’s details will be handled. By default the input email is checked vs the article author’s email. However, if you set this to ‘check-password’ then the content of the email field of the comment form will be compared against the article author’s password.
NOTE: ‘check-password’ will leave a plain-text password trail in one of TXP’s internal tables.
Examples…
If you don’t want to use the default class names then you can override them thus…
<txp:sed_get_comment_class class='foo' author_class='auth' odd_class='o' even_class='e' />
Standard comments, odd, will be marked: ‘foo o’.
Standard comments, even, will be marked: ‘foo e’.
Author’s comments, even, will be marked: ‘foo e auth’.
If you don’t want odd/even output…
<txp:sed_get_comment_class hide_odd_even='1' />
If you don’t want author checking output…
<txp:sed_get_comment_class author_class='' />
If you don’t want author checking or odd/even output…
<txp:sed_get_comment_class author_class='' hide_odd_even='1' /> …but then again, it would be easier just to fix the div class name to ‘comments’!!!
If you want to check for author comments against the TXP users’ passwords then…
<txp:sed_get_comment_class method='check-password' /> NOTE This will record the TXP user’s password in plaintext in the txp_discuss table. It’s up to you if you want to do this but it might be better to stick with the default ‘check-email’ method and have each TXP user supply an un-publicised email address when their account is created in TXP.
<txp:sed_if_author_comment_string/>
I use this to append a string such as ’ (Author Comment)’ to all comments left by the author of the article, but you can customise the strings returned for author and non-author situations.
| Attribute | Default Value | Description |
| ‘string’ | ’ (Author Comment)’ | This string is returned if there is an author match. |
| ‘else_string’ | ‘’ | This string is returned if there is not. |
| ‘wraptag’ | ‘span’ | Used to wrap the author string if it is returned. |
| ‘class’ | ‘author-string’ | Used to set the class value of the wrapped author string. |
| ‘method’ | ‘check-email’ | Method to use when checking for an author match (see above). |
Note: The ‘else_string’ is not ‘wrapped and classed’.
<txp:sed_comment_number/>
Replacement for ajw_comment_num so that we don’t have to load additional plugins to handle this common situation.
| Attribute | Default Value | Description |
| ‘count’ | ‘up’ | Specifies how comment numbers will change, comment to comment. Valid values are ‘up’, ‘down’, ‘guestbook’. Only use the ‘guestbook’ count mode for integration with the sdr_guestbook plugin. |
<txp:sed_comment_time/>
Replacement for the native txp tag comment_time but extended to allow for a wraptag and class.
| Attribute | Default Value | Description |
| ‘wraptag’ | ‘span’ | Used to wrap the returned time. |
| ‘class’ | ‘comment-time’ | Used to tag the structure for CSS markup. |
| ‘format’ | TXP default | The desired time in strftime format. |
<txp:sed_if_comments/>
This is a straight replacement for the <txp:if_comments/> tag. It accepts no attributes. This version is not limited to use in TXP forms, it may be used in TXP page templates.
That’s it for the tags.
CSS classes and markup
The following CSS classes are used in the output of this plugin…
| Value | Location and use |
| .comment (or your named class) | Basic style applied to all comments |
| .author (or your named class) | Style applied to comments that match the article author. |
| .odd (or your named class) | Style for odd numbered comments. |
| .even (or your named class) | Style for even numbered comments. |
| .comment-time (or your named class) | Style for comment times. |
| .author_string (or your named class) | Style for appended author strings. |
The CSS markup needed for integration with the guestbook is unsupported, please see the guestbook plugin’s help file.
Here is a snippet of a CSS file to style the output list in a nice way. Alternate row striping is done by defining a different background colour for the odd rows.
| # | Code |
|---|---|
| 0001 | .comment { border: 1px solid #eee; padding: 10px; margin: 5px 0; background-color: #ffffff; } |
| 0002 | .odd { background-color: #f0f0f0; } |
| 0003 | .even { } |
| 0004 | .author { border: 1px dotted #333; } |
| 0005 | .comment h5 { margin-bottom: 0.1em; } |
| 0006 | .comment:hover { border: 1px solid #333; } |
| 0007 | .author:hover { background-color: #e6e6fa; } |
| 0008 | .comment-time { width: 90%; text-align: right; font-size: smaller; color: orange; } |
| 0009 | .author-string { font-variant: small-caps; font-weight: 100; } |
| 0010 | .comment-no { font-size: 1.5em; color: #999; } |
Credits
Inspired by the AJW_ family of plugins from Compooter
Guestbook integration was a collaboration with Els from the textpattern forum.