Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
small mod to rsx_word_count
I needed a site-wide word count, and it didn’t have to be 100% accurate. Not sure if this is of interest, or if someone else has done it, but here it is.
I used rsx_total_word_count (found here) in an attempt to get a site-wide word count, but it outputs total characters, not words. To get a ROUGH total word count, I did the following change to the plugin code:
Deleted this line (or comment it out):
return getThing("select sum(length(body)) from textpattern");
Added this line:
return intval(getThing("select sum(length(body)) from textpattern") / 5);
All it does is divide the returned value (which is the total number of characters in the body of the db) by 5 and truncate the decimal. Why 5? Because the average English word is 5 characters long. That value will vary for other languages, depending on your source of information. Obviously, the returned value is VERY approximate, but it’ll be in the ballpark. Something along the lines of “There are approximately x words on this site” would be a good caveat.
“I love Beethoven. Especially the poems.”
- Ringo Starr
Offline
Pages: 1