an7_comments

iaian7 » code » txp   John Einselen, 4.07.07 (updated 10.04.11)    

an7_comments gives a little more power in setting up comment invitations and comment counts; set up custom messages for 0, 1, or more comments, and a global comment invitation (overriding the individual article comment invitation text, so you can easily change the invitation for the entire site).

Version 0.5 adds support for mediaboxAdvanced overlays, instead of the standard popup window.

examples

In an article with no comments:

<txp:an7_comments_invite comment="leave a comment? " count0="there aren't any yet..." count1="one comment" count2="# comments and counting" />

leave a comment? there aren’t any yet!

In an article with 3 comments:

<txp:an7_comments_count count0="there aren't any yet..." count1="one comment" count2="# comments and counting" />

3 comments and counting

All variables can be set in the plugin code, letting you use the shorter <txp:an7_comments_invite /> or <txp:an7_comments_count /> without any extra baggage.

tags

<txp:an7_comments_invite />

Outputs a link to the Textpattern popup submission form (set to always show, unlike the Textpattern popup tag), along with the comment count. Each of the following settings can be defined in each use of the tag, or in the plugin code as a global default. The # symbol is replaced with the number of comments (or in the case of the overlay gallery set, the article ID).

comment="leave a comment" – Text used as the submit comment link

count0="no comments yet" – Display for when there are no comments

count1="one comment" – Display for one comment

count2="# comments" – Display for more than one comment

showcount="true" – Show comment count, true / false

width="480" – Width of the popup window, in pixels

height="500" – Height of the popup window, in pixels

class="an7_comment_invite"CSS class applied to the link

wraptag="none"HTML tag (without brackets), “none” sets no tag

wrapclass=""CSS class applied to the wrap tag (if applicable)

New feature (requires mediaboxAdvanced or compatible script):

overlay="true" – Use lightbox-style overlay instead of popup window

lightbox="lightbox" – Used for the the rel attribute, included to support non-lightbox scripts

set="comment#" – Controls the grouping of lightbox media, using # inserts the article ID, thereby creating individual sets.

<txp:an7_comments_count />

Outputs only the comment count, allowing you to use Textpattern’s own comment invitation links, but retain an7_comment’s more customizable comment count display. The # symbol is replaced with the number of comments.

count0="no comments yet" – Display for when there are no comments

count1="one comment" – Display for one comment

count2="# comments" – Display for more than one comment

wraptag="none"HTML tag (without brackets), “none” sets no tag

wrapclass=""CSS class applied to the wrap tag (if applicable)

<txp:an7_comments_author />

A very simple tag that checks a comment’s email address against a hard coded value. This lets you specify a value other than the admin email address – for example, highlighting a featured guest blogger’s comments, or using a lengthier string to create a secure email code. Returns the specified text if it matches, nothing if it doesn’t. Useful for defining author-only styles or similar effects. Should only be used in a comment form.

verify="emailaddress.com”@ – String to match against the comment address
string="_author" – Output string if the comment address field matches the Verify string

download

an7_comments (version 0.5)

To use the overlay feature, you’ll need mediaboxAdvanced and all associated support files (specifically, the MooTools library).

installation

Open the textpattern plugin file and copy / paste the text into your Textpattern “install plugin” field (Admin > Plugins). Finish the installation procedure and enable the plugin. That should be it!

If you want to use just the comment invitation, leave the count0/1/2 fields blank. This can also be used to place the comment count first, and follow it by an invitation to leave another one. Not the most elegant solution, but I’m kinda trying to stick closer to the Textpattern formula (where the comment count tag has a built in counter, and then a separate counter tag if need be).

version history

Please help improve this plugin by reporting errors, issues, or comments via email

v0.5.0
— added overlay support via mediaboxAdvanced
v0.4.0
— updates, added simple author check
v0.3.0
— public release, help file and php commenting updated
v0.2.0
— beta release, tested in a production environment
v0.1.0
— alpha release

help and support

For questions and support, please visit the an7_comments post in the Textpattern Forums.

credits

The thresholdstate.com tutorials were helpful as always, as was php.net.

ben, 29.08.07

Thanks for the plugin, John!

bookmark