The explode function looks for spaces, and so misses line and paragraph breaks. Improving this algorithm was listed as a TODO in the code, but it specifically referred to doing a better job for foreign languages and I'm not sure what the approach would be there.
I also haven't looked to see if this has changed in six, nor if there might be a CCK way that is superior. Just raising the issue and offering to try and make a patch if there's any thoughts/consensus on the approach for the word-count algorithm.
More notes here:
http://agaricdesign.com/note/allow-textfields-be-required-but-fewer-10-w...
(Below notes mostly about a related issue-- 10 is pretty high as the minimum number of words for merely requiring a node body. If there's interest in a patch for that, or knowledge of a contributed module that form_alters this or would be a good home for a tweak allowing a lower minimum word count, please let Agaric know.)
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | wordcount_9.patch | 755 bytes | Guillaume Beaulieu |
| #8 | wordcount_8.patch | 938 bytes | pancho |
| #4 | numword53.patch | 724 bytes | Guillaume Beaulieu |
| #2 | numwordfix.patch | 1.14 KB | Guillaume Beaulieu |
Comments
Comment #1
Guillaume Beaulieu commentedI'll fix that
Comment #2
Guillaume Beaulieu commentedI've included a patch to change explode(' ', $str) into pregsplit('[\s]+', $str).
It might be slower, but will definitely interpret two words separated by comma and no space as two words.
To change the minimal number of words required, you can go to admin/content/types/(whatever type of content), at least in the current cvs version.
Comment #3
mlncn commentedQuick work! That looks like it would do it, however I can't get the patch to apply to 5.3 or 5.2. I'm following the documentation as I've interpreted it; could someone point out where I'm wrong or do I need to apply this to dev?
I tried several things, including this command from root, modules, and node:
patch < numwordfix.patchComment #4
Guillaume Beaulieu commentedSorry, I fixed it for the CVS HEAD, here's the 5.3 version of the patch
Comment #5
Guillaume Beaulieu commentedComment #6
mlncn commentedThis works!
(Really, I should have tried this on Drupal 5 dev or even 6 head, and we should have changed the version). Marking ready-to-be-committed anyway to get the attention of keepers of the core.
Comment #7
drumm- We do not use $camelCase, we use $underscored_names.
- [] does not need to surround \s
- I would like to see this committed to Drupal 6 first, then backported to 5.x.
Comment #8
panchoCreated a patch against HEAD with renamed variable and simplified regexp.
Comment #9
Guillaume Beaulieu commentedIt has been fixed without the use of a regexp as of 6.2.
Comment #10
Guillaume Beaulieu commentedIn fact, this would fix it. Sorry for closing something that shouldn't have been close in the first place
Comment #11
dpearcefl commentedDoes this issue exist in current D6?
Comment #12
dpearcefl commentedWe want your patch if it is still needed. Please resubmit it with a proper filename.
http://drupal.org/node/1054616
[description]-[issue-number]-[comment-number].patch