Coder Social home page Coder Social logo

hdpero / silverstripe-text-target-length Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonom/silverstripe-text-target-length

0.0 2.0 0.0 36 KB

Set character length recommendations on SilverStripe text form fields

License: BSD 3-Clause "New" or "Revised" License

PHP 47.38% CSS 9.12% JavaScript 43.50%

silverstripe-text-target-length's Introduction

Text Target Length for SilverStripe CMS

Character limits in action

If you see a field marked 'Description' you know roughly what type of content to put in there. But how do you know how much of it to write? A single sentence might do, but maybe a paragraph or more is required? A great content plan should recommend an ideal length for every type of content, so content authors and designers alike can make informed decisions.

This module extends the TextField, TextareaField and HTMLEditorField classes in SilverStripe to allow you to set a recommended content length, and set soft upper and lower limits on character count.

Requirements

SilverStripe 3.1+ (3.3 tested)

Installation

Composer (best practice)

Packagist listing and installation instructions

Manually

I promise it's worth your time to learn how to use Composer. If painless updating isn't your thing though you can download and extract this project, rename the module folder 'text-target-length', place it in your project root and run a dev/build?flush=1.

How to use

With the module installed you can call call setTargetLength() on TextField, TextareaField and HTMLEditorField form fields.

// Ideal length: 100 characters
// Minimum: 75 (automatically set at 75% of ideal)
// Maximum: 125 (automatically set at 125% of ideal)
$field->setTargetLength(100);

// Ideal length: 100 characters
// Minimum: 25
// Maximum: 150
$field->setTargetLength(100, 25, 150);

// Prefer to think in word count?
// 6 characters per word works okay for English
$field->setTargetLength(50*6);

Customise hint text

This module supports translation through yml, so if you want to change the hint text that is displayed when users are typing, just create your own language file to override the one included in the module.

Want to see more like this?

I donate a lot of my time to open-source projects, so if you use this module in a commercial project a small donation to keep me motivated would be much appreciated. If you'd like to sponsor additional development on this module I'd love to hear from you.

Donate

To Do

  • Translation
  • Customise hint text through config

Maintainer contact

jonathonmenz.com

silverstripe-text-target-length's People

Contributors

jonom avatar hdpero avatar satrun77 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.