Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[plugin] [ORPHAN] afa_article_info
This is my first plugin: afa_article_info. It counts the number of words and characters in article edit mode, in (semi-)real time.
- v0.2 fixes a bug with the
$overflow
text and includes the ability to display Advanced options and/or Textile help when editing an article.
Modifications
Except for translating some strings in the beginning of the plugin code, little modifications should be neccessary. No tags are required to make this plugin word, just start editing your articles and watch the plugin at work.
Limiting user input
$maxfield |
If needed, you can define a field that contains a numeric value used as a max limit for the total amount of text you want to allow (e.g. ‘custom_1’). This is handy for when you request an article by a freelancer and want to limit the length of the story. Well, ‘limiting’ is not quite right – you’re still able to enter more text than what’s requested (it’s not like those web based SMS-apps everyone dislike so much…) |
---|
When exceeded, the text defined in $overflow
is displayed below in red.
Strings
$chars | The word ‘characters’ in your language of choice |
---|---|
$words | The word ‘words’ |
$ofmax | The word ‘of requested’ |
$written | The word ‘written’ |
$overflow | The sentence ‘You have written more than what has been requested of you, the story could be shortened by the editors’ |
$permlink | The matching entry for gTxt(‘permlink’), displayed next to the count info for easy access to the public side of the article |
Requirements
- The str_word_count() method requires PHP 4 >= 4.3.0, PHP 5
- The utf8_decode() method requires the XML library, IIRC
Known issues
There’s a big ‘doh’ type of bug currently – the max value doesn’t combine the Body and Excerpt field when checking for the max length. I’ll try to think of a way to overcome this embarrasing bug, please fill me in if you come to think of anything..
Credits
- Alex Shiels for the idea and a lot of the general code. This plugin is pretty much based on zem_article_info. I remade the counting though, to support international characters (it didn’t work at all for me before).
- Sarah King for the (static) Javascript functionality. I made it dynamic and removed the outdated browser sniffing code in favour of a more robust DOM-related thing.
Last edited by Anton (2005-10-15 17:29:22)
Offline
Pages: 1