Search

A new Extension, “Field: Character Count Textarea” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

This is another pretty simple extension. It installs a field for counting characters in a textarea field. There are limit and mode options, the limit is simply the maximum characters for the field, the mode, if set to strict, will make the message go red and indicate how many characters have been entered beyond the limit.

Screenshot

Character Count Textarea Field

Version: 1.1

Author: Eoghan O’Brien

Build Date: 2009-08-23

Requirements: Symphony 2.0.7

Installation

  1. Upload the folder in this archive to your Symphony ‘extensions’ folder and rename it to charactercounter_textarea.

  2. Enable it by selecting the “Field: Character Counter Textarea”, choose Enable from the with-selected menu, then click Apply.

  3. You can now add a “Character Counter” field to your sections.

Change log

2009-08-23: Added customizable messages, use $1 for the limit number and $2 for the current count along with your own message, e.g. $1 characters recommended. $2/$1 remaining

2009-08-23: Updated /fields/field.charactercounter_textarea.php to extend the native textarea field and overload the necessary methods (thanks nickdunn)

Github

http://github.com/eoghanobrien/sym_charactercount_textinput/tree/master

Excellent work eoghanobrien! This will be very useful indeed.

In fact, you beat me to it — I had Character Limits ready but never got round to releasing it.

I look the alternative route of allowing the count to be applied to any text input or textarea, so instead of a new field type, one specifies the fields to which it should be applied to in the JavaScript. Not as user-friendly as yours (since it requires some JS editing to configure) but it has the bonus that the validation can be added to any field whatsoever (standard Input or Textarea, a Number field, a Date field…).

If you take a look at my JavaScript I’ve fairly successfully reverse-engineered some of the Markdown regular expressions so that when using Markdown these characters aren’t included in the character count. It’s currently specifically desgined for the markItUp editor/text formatter, but it has potential to be used more generically.

Perhaps we could merge ideas from both?

One thing I noticed in your field PHP files — if you’re replicating an exiting field (i.e. text input or textarea) it might be a better idea to inherit/extend the existing class and override only the methods you are changing. If bugs are found in either of these system fields then they can be patched and your extension won’t still include the bugs.

For a great example of this, look at michael-e’s Unique Upload field. He extends the native FileUpload field, including only the class methods he is changing in his own field.

Great extension though, thank you for releasing. This requirement came up at work only last week :-)

I took the alternative route of allowing the count to be applied to any text input or textarea, so instead of a new field type, one specifies the fields to which it should be applied to in the JavaScript. Not as user-friendly as yours (since it requires some JS editing to configure) but it has the bonus that the validation can be added to any field whatsoever (standard Input or Textarea, a Number field, a Date field…).

I like the idea of adding the character count to any textinput/textarea but I’d be a little slow to remove the fields as it allows a lot of flexibility for different types of counts.

For example, its recommended that page titles be no more than 66 characters, meta keywords 100 characters and meta description 150 characters and it was this I had in mind when I created it, although it can be used in may other situations. (Which is why I released it)

Perhaps we could merge ideas from both?

Yeah, absolutely. I’m not very experienced with the more advanced side of javascript but I’d definitely be willing to give it a go.

One thing I noticed in your field PHP files — if you’re replicating an exiting field (i.e. text input or textarea) it might be a better idea to inherit/extend the existing class and override only the methods you are changing. If bugs are found in either of these system fields then they can be patched and your extension won’t still include the bugs.

Good call on this, I thought about that this morning myself, I’ll update soon.

One thing I noticed in your field PHP files — if you’re replicating an exiting field (i.e. text input or textarea) it might be a better idea to inherit/extend the existing class and override only the methods you are changing. If bugs are found in either of these system fields then they can be patched and your extension won’t still include the bugs.

For a great example of this, look at michael-e’s Unique Upload field. He extends the native FileUpload field, including only the class methods he is changing in his own field.

I need to check this out and make sure my color chooser field is that way. Thanks!

Thank you for naming my extension, Nick. Actually I will have to send all those flowers to Rowan Lewis, because I borrowed all the basic code from him. This is from my extension’s README:

This extension is a variation of the ‘Hashed Upload Field’ extension by Rowan Lewis.

And this is from the licence file:

Copyright 2008-2009 Rowan Lewis, Michael Eichelsdoerfer

So big thanks to Rowan.

@eoghanobrien: Thanks for this extension!

Note: Your GitHub link above is actually pointing to the Character Counter Textarea extension instead of the Character Counter Text Input extension.

@bauhouse, no problem, thanks for the heads up on the link and for adding the counters to your extension library

Field: Character Counter Textarea updated to version 1.2 on 30th of November 2009

nice script . i have implemented a similar thing with a progress bar using Jquery . you can find the tutorial and a live demo here : http://youhack.me/2010/04/22/live-character-count-with-progress-bar-using-jquery/

I've just tried to implement these on a 2.2.1 build of Symphony and it breaks my site, as does the text input version of this extension. I noticed the Github is also removed - is this extension still actively being developed or are there any alternatives?

The Text Box Field has incorporated the abilities of the two Character Counter fields.

It seems that @eoghanobrien has deleted the fields due to this.

It would have been nice to have a heads up, so they can be retired on the extensions list. Any forum mods out there, can you retire the fields in the list please?

Thanks.

I've flagged these extensions as "RETIRED" in the listing...

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details