webcoast/character-counter

Show a character counter below text fields in TYPO3 CMS

Installs: 286

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 2

Open Issues: 1

Type:typo3-cms-extension

v1.0.0 2021-06-23 13:34 UTC

This package is auto-updated.

Last update: 2024-11-23 21:56:25 UTC


README

What does it do?

This extension allows you to display a character counter in the form of 23 / 60 below input fields, text areas and RTE fields. This is most useful for SEO related fields, so that editors get a hint, if their title or description matches the requirement.

This does not limit the number of characters, that can be entered. This counter is for informational purpose only.

Installation & configuration

The extension is available from packagist.org

composer require webcoast/character-counter

or from TYPO3 extension repository.

Usage

To enable the character counter for a certain field, use the TCA helper method in your TCA/Overrides files.

Pages: seo_title

In Configuration/TCA/Overrides/pages.php add:

\WEBcoast\CharacterCounter\Helper\Tca::enableCharacterCounter('pages', 'seo_title', 60, 40);

The last argument warning is optional and defaults to 80% of the third argument max.

You can also adjust your TCA manually by adding the follow to the field's config section:

\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['pages']['columns']['seo_title']['config'], [
    'fieldWizard' => [
        'characterCount' => [
                'renderType' => 'characterCountWizard'
            ]
        ],
        'characterCount' => [
            'warning' => 120, // Optional: Defaults to 80% of `max`
            'max' => 160
        ]
    ]
);

Contributing

Feel free to fork and provide a PR or open an issue.