1
chaymation
having "words more" not "bytes more" in news items
  • 2005/1/9 0:49

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


is there a way to have it calculate how many more words there are to read in the extended text of a News item, rather than having "1998 bytes more" or something. I'd like it to say "392 words more". I know this is possible in other content management systems but I can't seem to figure it out in this one.

Cheers

2
davidl2
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 0:58

  • davidl2

  • XOOPS is my life!

  • Posts: 4843

  • Since: 2003/5/26


Characters more may be better...

3
chaymation
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 12:07

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


"Characters more" might be easier, but also more geeky than I'd want.

When writing an essay in word, i never say to myself "oh look it's 10,000 characters long" I only care that the word count is 1,800.

Users can judge word count more easily than character count and know whether the news item is a couple of paragraphs, a mid sized rant or a massive essay!

I'd like it to do what word does, count the words in the extended text then have "350 words more". "bytes more" would mean nothing to my audience, "characters more" wouldn't be much better.

I haven't a clue how you would do this though!

4
Mithrandir
Re: having "words more" not "bytes more" in news items

Look for
strlen(trim($this->bodytext()));

in your module - might be $story->bodytext() I can't remember, how it was structured in the original News module.

Change it to:
substr_count(trim($this->bodytext()), ' ');


Not tested, though (and remember that there will be an assignment of "$some_variable =" before the strlen. that will need to remain.

5
chaymation
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 13:22

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


Thanks for the help so far.
What file of the module will I find that line in?

(Also I'm using News 1.2.1)

6
Mithrandir
Re: having "words more" not "bytes more" in news items

modules/news/class/class.newsstory.php - toArray() method, I believe.

7
chaymation
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 13:25

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


Goodness, you are fast!
I'll just go try that and report back!

Thanks!

8
chaymation
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 13:36

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


I found this:

Quote:
$introcount = strlen($story['text']);
$fullcount = strlen($this->bodytext());
$totalcount = $introcount + $fullcount;


In the class.newsstory.php file

changing it like you said to

Quote:
$introcount = strlen($story['text']);
$fullcount = substr_count(trim($this->bodytext()), ' ');
$totalcount = $introcount + $fullcount;


I think it does something to the number (reduces it) but it doesnt seem to be either the word count or the character count

9
chaymation
Re: having "words more" not "bytes more" in news items
  • 2005/1/9 13:39

  • chaymation

  • Just popping in

  • Posts: 27

  • Since: 2005/1/9 0


when i changed it, it displayed "880 bytes more" when previously it had been "1998 bytes more" on one of my posts
the word count for the post is about 350

10
Mithrandir
Re: having "words more" not "bytes more" in news items

Ok, take a step back and look at what you are doing, will ya?

$introcount strlen($story['text']);
$fullcount strlen($this->bodytext());
$totalcount $introcount $fullcount;

Ok, so I didn't give you absolute specifications, but isn't it obvious that what it does is give the total count? So naturally, when you count words in the bodytext, you should also do it when computing the word count in the introcount.

I'm sorry for not being specific enough, I was looking at AMS because I didn't remember changing that area, when I made AMS. I was wrong.

To get the wording "words more" instead of "bytes more", you should edit the modules/news/language/english/main.php

Login

Who's Online

198 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 198


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits