dev.michaelgravel.com

textpattern ~ code ~ css

Oct 20 2007

Plugin: mg_comments_count

The plugin <txp:mg_comments_count /> returns the number of comments on a post followed by the word of your choice. It’s a simple plugin that adds some user friendliness to comment display.

Attributes

This plugin takes three attributes:

  • zero: The text to display if there are no comments. NOTE: A zero numeral is NOT returned. Defaults to ‘No comments’.
  • one: The text to display if there is one comment. The number “1” will precede the text. Defaults to ’1 comment’.
  • many: The text to display if there is more than 1 comment. The number of comments will precede the text. Defaults to ‘x comments’.

Examples

Example #1

<txp:mg_comments_count />

The above would output the following:

  • “No comments” if there are no comments
  • “1 comment” if there is one comment
  • “16 comments” if there are 16 comments

Example #2

<txp:mg_comments_count zero="Not a single comment yet." one="One lonely comment." many="hot comments so far." />

The above would output the following:

  • “Not a single comment yet.” if there are no comments
  • “One lonely comment.” if there is one comment
  • “16 hot comments so far.” if there are 16 comments

Notes on usage

Typically, I use this plugin at the top of my comment display. It could also be worked into a comment invite if you combine it with a few conditionals.

Credits

Written by Michael Gravel.

Posted in text on October 20, 2007

No comments

Commenting disabled.

Text

Welcome to the Text archives. This is where I write about Textpattern, a lightweight, PHP-based content management system.

side image

Textpattern Plugins

I've made a few plugins for Textpattern that provide very modest additions to the software's existing functionality. Here they are: