2

Any way to show the total word count in real-time to authors while they are writing an entry that has multiple blocks?

I don't need per-block word count ... I need total word count shown in real-time.

2 Answers 2

1

What you want to achieve is not an easy task because you would have to hook into many different events to recognize new blocktypes.

The fastest and easiest method would be to use this plugin as the base of your own https://github.com/mmikkel/CpFieldLinks-Craft/blob/master/README.md. You can edit the init function to show the script for everyone and not just administrators. Then you use the plugins Javascript function as your base script https://github.com/mmikkel/CpFieldLinks-Craft/blob/master/source/javascripts/CpFieldLinks.js and change the editFieldBtn template to display not the handle of your field but a custom variable. This variable will be the total word count.

You have to select all your needed fields with jquery (inspect the html in order to find out what selectors you can use) and use a word count script.

I`ve created something similar a few months ago and did the same. It was relatively easy compared to do all the work from zero

1

You'll need to add a plugin like this one from Lindsey DiLoreto that allows you to insert your own javascript into the CP. Then you'll need to write some javascript that counts up each word in a textarea input for each block. I'm sure stackoverflow has several answers on how to do that. Keep in mind Craft already has jQuery installed if you choose to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.