Word count and character counts on post

https://www.phpbb.com/ideas/
User avatar
exatienda.com
Registered User
Posts: 27
Joined: Sat Sep 07, 2013 12:53 pm
Contact:

Word count and character counts on post

Post by exatienda.com » Sat Sep 07, 2013 2:08 pm

Hello to everyone,

Here it is my contribution, I programmed a word and character count of the post on the first page of my forum.

What you have to do is:

1.- Enable php code on ACP->General->Security configuration->Enable PHP->Yes.

2.- Edit your ../template/index_body.html

3.- Find this line:

Code: Select all

<div class="statspanel" style="background-image: url('{T_THEME_PATH}/images/statistics.png');">
4.- After add this:

Code: Select all

<!-- PHP -->
$con=mysql_connect("127.0.0.1","usuer_of_database","password_MySQL"); .

   $con2 = mysql_select_db("your_database"); 

   $Post = mysql_query("SELECT post_subject,post_text FROM database_name_posts") or die (mysql_error());
   $num_reg_mes=mysql_num_rows($Post);
   while ($row = mysql_fetch_array($Post))       
      {
      $Number_characters_tites.=$row['post_subject'];
      $Number_characters_tites_2.=$row['post_subject']." ";
      $Number_characters_posts.=$row['post_text'];
      $Number_characters_posts_2.=$row['post_text']." ";
      }
      $Result_characters = (int)strlen($$Number_characters_titles) + (int)strlen($Number_characters_posts);
      $Result_words_tmp_1 = (int)substr_count($Number_characters_titles_2,' ');
      $Result_words_tmp_2 = (int)substr_count($Number_characters_posts_2,' ');
      $Result_words =$Result_words_tmp_1+$Result_words_tmp_2;
      <!-- ENDPHP -->
5.- On the bottom of our statistic box we put:

Code: Select all

{TOTAL_POSTS} &bull; {TOTAL_TOPICS} &bull; {TOTAL_USERS} &bull; {NEWEST_USER} <br />Words and characters typed on posts: <!-- PHP --> echo "<b>".$Result_words."</b> words and <b>".$Result_characters."</b> characters."; <!-- ENDPHP -->
I know that the code can be more optimized but this is a funny feature of statistics!! :D

----------

View idea at: Word count and character counts on post

Posted by exatienda.com

User avatar
callumacrae
Former Team Member
Posts: 2662
Joined: Tue Feb 12, 2008 12:28 pm
Location: London, UK
Name: Callum Macrae
Contact:

Re: Word count and character counts on post

Post by callumacrae » Mon Sep 09, 2013 5:03 pm

Why?
macr.ae = my website. you probably won't like it.
Proud user ofProud user of

User avatar
AmigoJack
Registered User
Posts: 5605
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Word count and character counts on post

Post by AmigoJack » Thu Sep 12, 2013 5:30 am

The code is horrible: it doesn't use the DBALayer, doesn't honour UTF-8, won't count words if they're each on an own line, impacts server performance, doesn't cache results, doesn't consider using DBMS-offered string length functions to avoid transfering all the data and on top it has several typos.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
D@ve
Registered User
Posts: 143
Joined: Sat Aug 28, 2004 12:49 am
Location: Germany, Bretzfeld D.C.
Name: Dave Remmel
Contact:

Re: Word count and character counts on post

Post by D@ve » Wed Oct 02, 2013 8:50 am

Don't blame the code... The idea is good...

If you have a character limit it would be cool to display the amount of the character (the lines of Javascript)
2jesus.de - (german community for bible & faith)
phpBB.de - the German support community for pbpBB

User avatar
KevC
Support Team Member
Support Team Member
Posts: 69300
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: Word count and character counts on post

Post by KevC » Wed Oct 02, 2013 9:42 am

D@ve wrote:Don't blame the code... The idea is good...

If you have a character limit it would be cool to display the amount of the character (the lines of Javascript)
But why?
I can't see a single reason for being able to see how many characters or words are in the post you just wrote in a system where the upper limit is so high it's rarely met.

It's only relevant on something like SMS or twitter where you're limited to 140 or 160 characters per message.

OMG that was 57 words and 289 characters. :)
-:|:- Support Request Template -:|:-
Image
Cheap UK Hosting
"In the land of the blind the little green bloke with no pupils is king - init!"

User avatar
peopleopinion
Registered User
Posts: 372
Joined: Thu Nov 07, 2013 7:12 pm
Contact:

Re: Word count and character counts on post

Post by peopleopinion » Sat Nov 16, 2013 12:52 am

Kevin Clark wrote:
D@ve wrote:Don't blame the code... The idea is good...

If you have a character limit it would be cool to display the amount of the character (the lines of Javascript)
But why?
I can't see a single reason for being able to see how many characters or words are in the post you just wrote in a system where the upper limit is so high it's rarely met.

It's only relevant on something like SMS or twitter where you're limited to 140 or 160 characters per message.

OMG that was 57 words and 289 characters. :)

Some admins use to be restrictives in chars limits for posting and for pm signature. To have a reference that tell users how they can type in total and how they have already typed can be a way to give the user the possibility to organize better the response (s)he is writing.

Any way, there are some styles that already have a feature that shows the max limit at the flank of the text area, so it is half work to add a new feature that shows in real time typed chars count and add such feature at other text areas as signature, pm, quick response, etc.

Anyway I agree with what D@ve wrote. The strange thing is that D@ve didn't vote (neither positive nor negative). :|

I have also requested this here without knowing the exatienda.com's idea:
viewtopic.php?f=436&t=2211216

And here viewtopic.php?f=70&t=2210986 I reported of a little Mod to show to users the post max number of allowed chars, if some one is interessed at.
As might be phpbb admins know this last one is an existing feature in some styles but not all. So I recovered some code from a style that already have it and just copied into another style that have not.
Of course this last one is a little off topic but I felt, however, that they were strictly related things.
Hope this helps
Please explicate why you voted negative or positive, so it will be possible to better understand each one's point of view.
Please visit and vote my website and express freely your opinion on it (phpbb ver.: 3.0.12):
http://peopleopinion.altervista.org
Thanks. Best Regards, peopleopinion.

User avatar
D@ve
Registered User
Posts: 143
Joined: Sat Aug 28, 2004 12:49 am
Location: Germany, Bretzfeld D.C.
Name: Dave Remmel
Contact:

Re: Word count and character counts on post

Post by D@ve » Sat Nov 16, 2013 10:31 am

But why?
I can't see a single reason for being able to see how many characters or words are in the post you just wrote in a system where the upper limit is so high it's rarely met.
In our forum the limit is not that high. And the users are complaining about having a charachter limit on one hand and having no character count at the other.

phpBB offers the option to limit the chracters per post, so its logical to give the users the option to check their posts against that limit. Many of our users are writing their posts in word for that reason.

regards, Dave
2jesus.de - (german community for bible & faith)
phpBB.de - the German support community for pbpBB

User avatar
callumacrae
Former Team Member
Posts: 2662
Joined: Tue Feb 12, 2008 12:28 pm
Location: London, UK
Name: Callum Macrae
Contact:

Re: Word count and character counts on post

Post by callumacrae » Sat Nov 16, 2013 1:42 pm

D@ve wrote:
But why?
I can't see a single reason for being able to see how many characters or words are in the post you just wrote in a system where the upper limit is so high it's rarely met.
In our forum the limit is not that high. And the users are complaining about having a charachter limit on one hand and having no character count at the other.

phpBB offers the option to limit the chracters per post, so its logical to give the users the option to check their posts against that limit. Many of our users are writing their posts in word for that reason.

regards, Dave
Why not just raise the character limit?
macr.ae = my website. you probably won't like it.
Proud user ofProud user of

User avatar
D@ve
Registered User
Posts: 143
Joined: Sat Aug 28, 2004 12:49 am
Location: Germany, Bretzfeld D.C.
Name: Dave Remmel
Contact:

Re: Word count and character counts on post

Post by D@ve » Sat Nov 16, 2013 3:31 pm

Well, because I WANT that character limit. People use to post five A4 pages and more. That's simply too much for a forum.

Regards, Dave
2jesus.de - (german community for bible & faith)
phpBB.de - the German support community for pbpBB

User avatar
peopleopinion
Registered User
Posts: 372
Joined: Thu Nov 07, 2013 7:12 pm
Contact:

Re: Word count and character counts on post

Post by peopleopinion » Sun Nov 17, 2013 2:28 am

D@ve wrote: In our forum the limit is not that high. And the users are complaining about having a character limit on one hand and having no character count at the other.

phpBB offers the option to limit the characters per post, so its logical to give the users the option to check their posts against that limit. Many of our users are writing their posts in word for that reason.
I totally agree with this. And also it is a question of transparency of the service and of coherence: if there is a limitation, the limitation must be showed.

Of course could be present some option to activate or not: so if there is a limit the admin can show the counter, if not the admin can hide the counter.
Last edited by peopleopinion on Wed Nov 20, 2013 3:45 am, edited 1 time in total.
Please explicate why you voted negative or positive, so it will be possible to better understand each one's point of view.
Please visit and vote my website and express freely your opinion on it (phpbb ver.: 3.0.12):
http://peopleopinion.altervista.org
Thanks. Best Regards, peopleopinion.

User avatar
D@ve
Registered User
Posts: 143
Joined: Sat Aug 28, 2004 12:49 am
Location: Germany, Bretzfeld D.C.
Name: Dave Remmel
Contact:

Re: Word count and character counts on post

Post by D@ve » Sun Nov 17, 2013 9:54 am

I don't need a switch. If the limit is activated the counter could be activated too. If you don't want ist, you could delete it in the template.
2jesus.de - (german community for bible & faith)
phpBB.de - the German support community for pbpBB

User avatar
KevC
Support Team Member
Support Team Member
Posts: 69300
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: Word count and character counts on post

Post by KevC » Sun Nov 17, 2013 11:54 am

D@ve wrote:Well, because I WANT that character limit. People use to post five A4 pages and more. That's simply too much for a forum.
It would be better off as a MOD then as the number of boards it would be useful for is limited.
-:|:- Support Request Template -:|:-
Image
Cheap UK Hosting
"In the land of the blind the little green bloke with no pupils is king - init!"

User avatar
D@ve
Registered User
Posts: 143
Joined: Sat Aug 28, 2004 12:49 am
Location: Germany, Bretzfeld D.C.
Name: Dave Remmel
Contact:

Re: Word count and character counts on post

Post by D@ve » Sun Nov 17, 2013 12:30 pm

Well... the character limit is not a Mod, so why should the display of this limit for the end user should be a mod.
It's quite annoying to edit a post with too many charachters if you have to click submit everytime you want to check, if you matched the limit...
2jesus.de - (german community for bible & faith)
phpBB.de - the German support community for pbpBB

User avatar
callumacrae
Former Team Member
Posts: 2662
Joined: Tue Feb 12, 2008 12:28 pm
Location: London, UK
Name: Callum Macrae
Contact:

Re: Word count and character counts on post

Post by callumacrae » Mon Nov 18, 2013 11:15 am

D@ve wrote:Well... the character limit is not a Mod, so why should the display of this limit for the end user should be a mod.
Because -10 points
macr.ae = my website. you probably won't like it.
Proud user ofProud user of

User avatar
AmigoJack
Registered User
Posts: 5605
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Word count and character counts on post

Post by AmigoJack » Mon Nov 18, 2013 11:30 am

D@ve wrote:five A4 pages
Even if we consider this as measurement: People can also start using many linebreaks or including pictures with a large height to "increase" the post.

I understand the advantage of having a display of "characters left". However, the problem is to let JS count the same way the PHP code does - while you can easily do a .length it won't consider HTML entities sizes.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Post Reply

Return to “phpBB Ideas”