We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Extension: MD Character Count - display and limit the number of characters allowed for fields

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

For my current project, I needed a more robust character count that was was out there, so I started by looking at what Andrew Weaver had done with his, and came up with this offering.

MD Character Count will show character counts below textareas, text inputs, and MD Markitup fields in the CP. You can set character counts to “soft” (which is the default) which is more of a suggestion, or “hard” which will limit the field to that many characters and no more. You can also customize the message underneath each field.

You can download it from the MD Character Count page at Masuga Design.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Ryan,

Will post here as well as your site to say this is an excellent little extension well done and thanks for sharing it!!

Just one thing though I couldn’t seem to get this to work unless I enabled the jQuery For Control Panel extension. I thought from reading the documentation that it should work without it but couldn’t seem to get it to work like that. Works great though with the other extension on so thanks.

Best wishes,

Mark

       
Rob Quigley's avatar
Rob Quigley
236 posts
16 years ago
Rob Quigley's avatar Rob Quigley

This is really great. Just a feature request: it would be great if there was an option to count words instead of characters. I know I could use the word counter. 😊

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

@Mark: I would suggest always turning on the CP jQuery extension. If other extensions are written to look for this, it will help avoid conflicts.

This extension should definitely work without having to install CP jQuery, but it might not depending on whether you have other extensions installed that are also calling jQuery. If those others are older and not set up to look for other extensions also calling jQuery (like this one), sometimes jQuery can be loaded more than once in the head which can cause some extensions to fail. I’ve seen some of Leevi’s extensions fail because of this too (LG Data Matrix, in my testing). That’s the sort of the thing the CP jQuery extension was intended to help address.

@Rob: Word count would be nice, sure. And so would being able to ignore HTML. I’m not married to the jQuery plugin I’m using - it seemed lightweight, but I did have to modify it to allow for soft counts. If there is a better character/word counting jQuery extension out there, point me to it and maybe I can beef this up with some extra settings.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Ryan,

Ah right. Could possibly be another extension then although to tell the truth I don’t think any of the other extensions I have on the site use jQuery. Could be wrong on that though.

Anyway will just go with using the jQuery extension as that is much neater anyway.

Again thanks for a fantastic extension, really nice this one!! 😉

Best wishes,

Mark

       
ABDC's avatar
ABDC
71 posts
16 years ago
ABDC's avatar ABDC

I know your specs state that the plugin is MSM aware,

however when I change from site to site I get an error in my page above all HTML :

Notice: Undefined index: 2 in /www/htdocs/cebuco/http/system/extensions/ext.md_character_count.php on line 110

Where index 2 is the index of the site.

I used both the custom path for jquery, and when I encountered the problem the CP jquery extention. But that made no difference.

Any idea what can cause this? Thank you.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

Let’s make sure we’re on the same page. What version/build of EE are you using, and are you using PHP 4 or 5?

       
ABDC's avatar
ABDC
71 posts
16 years ago
ABDC's avatar ABDC

I am using EE 1.6.6 and PHP Version 5.2.6-5 Version 1.0.4 of your extention

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I’m setting up an MSM installation locally to test this and MD Live Search. Seems a few of my add-ons are having issues with their MSM abilities. Arrrgh.

       
smartpill's avatar
smartpill
456 posts
16 years ago
smartpill's avatar smartpill

Here’s a jQuery word count plugin I found. I need it for a SAEF, but might have something useful for the extension.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

Cool. I think it would be a good thing to specify whether you want words or characters counted on each field. The other nice thing would be to ignore HTML tags.

       
Garrett's avatar
Garrett
36 posts
16 years ago
Garrett's avatar Garrett

Ryan, any progress with the MSM undefined index errors? I am seeing the same errors when switching between sites:

Notice: Undefined index: 1 in /[path]/extensions/ext.md_character_count.php on line 96

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I haven’t fixed that. I think the only thing you need to do is go into the MDCC settings for that site and hit “Submit” once and that error should go away.

I would get on this, but I think the above will solve the issue for each site for now, and I have a certain EE-related site I’m trying to get launched as soon as possible. It’s on my to-do list, though.

       
Wes Baker's avatar
Wes Baker
343 posts
16 years ago
Wes Baker's avatar Wes Baker

I’m seeing notices as well and If it would help I’ve attached a dump from xdebug of the notices I’m seeing.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I’m almost 100% positive this has to do with the settings not getting set by default - hence having to hit “Submit” to get the settings in there. With a launch of devot:ee coming very soon I just don’t have time to get on this immediately. It’s still on my to-get-to list.

Thanks for posting the notices.

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.