Word / character count field

206 views
Skip to first unread message

Jonathon Menz

unread,
Nov 16, 2015, 7:39:26 PM11/16/15
to SilverStripe Core Development
Hi all,

I was thinking about content strategy and helping my clients write content of the right length and thought a text field where you could set a min, max and target character or word count could be useful. It could look something like this:


You often see a maximum length constraint on content but to me it's much more important to consider the ideal length.


I'm imagining you could set the tolerance on this field, so perhaps by default if you're within 10% of the target count you get the green light, but you could make it more or less strict.

I'm thinking this could start out as a module, but might be worth rolling in to core if it proves really useful. It could simply be an addition to TextareaField, activated through ->setConfig() similar to the way you can add a calendar widget to a DateField.

What do you all think? Is there anything like this out there already for SilverStripe, or form fields in general? I experienced content length hinting like this somewhere online once but can't recall where. If anyone has seen a jQuery plugin that already does this well or other relevant examples please point me in the right direction - I've seen lots of character limit plugins but nothing exactly like this so far.

p.s. (shameless plug) if you care about content, have a quick peek at Share Care, a little open graph add-on I released recently.

Sam Minnée

unread,
Nov 16, 2015, 8:27:48 PM11/16/15
to SilverStripe Core Development
I think that this would be great if this could be added as a module that could be applied to existing fields.

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Gordon Anderson

unread,
Nov 17, 2015, 1:38:24 AM11/17/15
to silverst...@googlegroups.com
hi Jonathan

There is an existing module which offers an SEO 'score' for a page based on heuristics, see https://github.com/micschk/silverstripe-liveseo

It does have a length metric, but this appears to be hard-coded to 300 words.  Perhaps fixing this to be configurable and possibly on a per class basis would be the way to go.  I can imagine for example the ideal length of a football player's profile being shorter than a football match report.

Cheers

Gordon

Jonathon Menz

unread,
Mar 10, 2016, 6:48:34 PM3/10/16
to SilverStripe Core Development
For anyone interested in this, have whipped up a module for this today. Feedback welcome. https://github.com/jonom/silverstripe-text-target-length

Mark Muller

unread,
Mar 11, 2016, 11:37:51 AM3/11/16
to SilverStripe Core Development
Nice module Jonathon!

Looking forward to seeing it expanded to include HTMLEditorField's. Does it support frontend forms?

Regards,

Mark

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Mar 11, 2016, 3:04:45 PM3/11/16
to silverstripe-dev
I am very curious what is "best practice" in terms of creating a form field with JS, such as the one showcased here. A field that works on the front-end and the back-end without any additional tricks. 

For example, I have developed a page rating module and, while my "rating" field works perfectly on the front-end, it does not work in the CMS [sad face goes here].  I would like to make that work using "best practice". 

Because entwine is on the way out, I was wondering if there is a better way (JS React might be a bit too forward thinking? as I also want it to work in 3.1).

THANK YA'LL
​Nicolaas​

Jonathon Menz

unread,
Mar 11, 2016, 3:33:45 PM3/11/16
to SilverStripe Core Development
Hi Mark, have updated the module this morning to make sure front-end forms work and added HTMLEditorField support (with a caveat)

@Nicolaas I don't know about best practice, but you can look at my script to see how I made the field work in front and back end. It should work out of the box which is convenient but on a production site if you're like me you're probably going to want to block those scripts being loaded through the Requirements API so you can combine them with your other front-end scripts and make sure you're not doubling up on jQuery instances.

Anselm Christophersen

unread,
Mar 12, 2016, 5:27:27 AM3/12/16
to silverst...@googlegroups.com
I think if you want it to work on 3.x you'll probably need to go with entwine for now.
As such I've got the feeling that we're in a transition period right now with no well established best practices.
I'm sure with 4.x and going forward, the best practice will become writing a react component, which essentially will switch out the jquery and entwine dependencies with react.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages