Documentation for the Textpattern plugin smd_article_stats by Stef Dawson follows this short message from our sponsor ;-)
If you like my code and it helps you out, feel free to show your appreciation with something from my UK Amazon wish list (or US) or donate to the Stef Dawson community coding pot, either via paypal.me/stefdawson by following the Donate button below to PayPal. Thanks!
Put this tag in your article form to display info about the current article. Tags are ignored in the calculation, as far as possible. Note that it only displays the actual number of words entered in the article itself — if some of the content is derived from other forms, it will not be included. The same goes for character counts: if there is markup or random content in the field you choose to tally, the plugin will make a best guess after it strips tags from the field.
- item : list of items you want to count. The most common ones are
titleto get the number of words in the relevant fields. You can supply any article field you like here (e.g. custom field:
item="body, book precis, book author"). If you don’t specify anything then the fields used will be those selected from the prefs.
- type : flavour of information you wish to display. Either
word(the default) or
- label : label text to output before the requested count.
- labeltag : HTML tag without brackets to wrap around the label.
- wraptag : HTML tag without brackets to wrap around the output.
- class : CSS classname to apply to the wraptag (default:
On the Write panel, the number of words/chars in the document are displayed in a stats panel. It is updated in real time as data is entered in the given fields (defined in the plugin preferences). The article ID can also be displayed; hyperlinked to the article itself if it’s live or sticky. Set the Show article ID preference accordingly.
If you wish to move the panel to a different location on the Write panel, visit the Advanced prefs. You can then choose one of the following items from the list:
- Above Sort and display : (default location) above the ‘Sort and display’ box.
- Above Title : above the Title box.
- Above Textfilter : above the Textfilter Help twisty.
- Below Textfilter : below the Textfilter Help twisty.
- Below Excerpt : Immediately beneath the Excerpt.
- Below Author : Beneath the author info (which is under the Excerpt). Note this position won’t appear for new articles until they are published.
- None : disable the panel.
You may also customize which fields contribute to the count by altering the value in the Word count fields and DOM selectors box. List the fields using the syntax field -> DOM selector and separate each field with a comma. For example, to count words in the body, excerpt and custom 2 fields, set the preference to:
Body -> #body, Excerpt -> #excerpt, custom_2 -> #custom-2
Author / credits
Written by Stef Dawson. Thanks to both zem and iblastoff for the original works that this plugin borrows as its foundation.
- 17 Mar 2016 | 0.40 | For Txp 4.6.0+ ; Added character count support ; fixed the default DOM anchors for new Write panel layout
- 21 Nov 2012 | 0.30 | For Txp 4.5.0+ ; added visible prefs ; made smd_article_stats tag take on defaults ; display of ID is optional
- 04 Apr 2012 | 0.24 | Expanded the available fields to anything in the article (thanks Teemu)
- 14 Feb 2012 | 0.23 | Fixed excerpt_below auto-update mechanism ; added author_below position
- 06 Jun 2011 | 0.22 | Added paragraph wrapper to fieldset for consistency with TXP’s layout (thanks philwareham)
- 22 Feb 2010 | 0.21 | Prevented error message if step mangled
- 07 Nov 2009 | 0.20 | Improved counting to ignore tags and added real-time admin-side counter (both thanks speeke)
- 24 Aug 2009 | 0.10 | Initial release
If you’d rather dig for buried treasure, you’ll need to step into the view source page.
If, for some inexplicable reason, you need a legacy version of a plugin, it can probably be found on the plugin archive page.
If you’re feeling brave, or fancy swimming with piranhas, you can test out some of my beta code. It can be found on the plugin beta page.