Question: you want to be able to see the word count for each post in phpBB3. How do you do that?
Answer: You need to edit two files in the phpBB3 code to get this to work. Read on.
We need to set up a variable called MESSAGE_ROW_COUNT, and display that in the template.
First of all, open /<phpbb3>/viewtopic.php and go to near line 1401. This is where the $postrow array is created.
$postrow = array(
// more code setting up $postrow elements
);
Somewhere in the middle, add this additional element:
'MESSAGE_WORD_COUNT' => str_word_count($message),
Then go to /styles/prosilver/template/ and go to line 189, and add this line:
<!-- IF postrow.POSTER_POSTS != '' --><dd><strong>Word Count:</strong> {postrow.MESSAGE_WORD_COUNT}</dd><!-- ENDIF -->
I put this in line 189, where it is just below the name and details of the person who posted the article. However, you may prefer to put it somewhere else.
Hello!
Firstly, I’d like to say thanks for this little hack explanation, it’s worked wonders.
Just curiously, are you aware of any way to perhaps modify the array entry so that the word count excludes any BB code? for instance, it’s registering a particular word count in a post on my forum as 40-odd words whereas the sentence is only just 20, and is considering the BB code to be a significant amount of the words.
Thanks!