Welcome to Geeklog, Anonymous Friday, April 26 2024 @ 03:27 am EDT

Geeklog Forums

How to not display number of views on short stories?


Goat

Anonymous
Hi,

I like to have the number of story views shown so my writers can see how popular or not their stories are. But with very short stories there's no need for users to click on "read more" as the whole story is on the front page, and so the hit counter doesn't go up much. This can make people think the story hasn't been read much - say 50 hits in amongst stories with 300 hits. Now of course there is no way of knowing whether people read the story, but is there a way I can stop "views" showing when the story was just a short one without the "read more" option?

Maybe if that isn't possible, perhaps I could do something like not display views if hits < 150, since it's unlikely more than 150 people would click on such a story if there's no "read more" (I think some people just click on the title no realising it's a short story, or they follow a link to the story from another site).

A related question is, when someone uses RSS to look at a story, does that show up as a hit?

Thanks,
Brett
www.worldfootynews.com
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by: Goat

A related question is, when someone uses RSS to look at a story, does that show up as a hit?


No. The view counter is only increased when you look at a story on the article page (article.php).

bye, Dirk
 Quote

Goat

Anonymous

That explains the RSS question (which means we may be much more widely read and don't realise it).

But any suggestions to stop stories of less than xx characters having the story count? Or stories having less than xx hits having the hit count show?

 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Assuming you are on 1.4.0 or higher, search lib-story.php for

if( $_CONF['hideviewscount'] != 1 ) {

and make it

if( $_CONF['hideviewscount'] != 1 && $A['hits'] > 150 && !empty($bodytext) ) {
 Quote

Goat

Anonymous
happy

Thank you VERY much for that. It was exactly what I was after. I've currently implemented it with just the empty bodytext check, not the number of views check. It does exactly what I wanted.

Cheers!
 Quote

Status: offline

worldfooty

Forum User
Full Member
Registered: 01/13/09
Posts: 162
Location:Mostly Adelaide, South Australia, Australia
I've been very happily using this for the last couple of years, except $A['hits'] isn't actually available in lib-story.php at this point (I don't think) so what I did was:

Text Formatted Code
    if( $_CONF['hideviewscount'] != 1 && $story->DisplayElements('hits') > 150 && !empty($bodytext) ) {



So that worked fine, except I just noticed that stories over 1000 hits were not showing. I eventually realised that
Text Formatted Code
DisplayElements('hits')
returns a formatted string with a comma in it, so 1000 is 1,000. So the operator treats it as two numbers, 1 and 000. So the logic returned is that 1 is not > 150, so the hits are not displayed. I demonstrated it to myself by setting hits for a story (in the database) to 151,000 and the views number was once again being displayed. 151 is > 150.

I thought ok, I need to get at the original unformatted hits or remove the comma. I couldn't see simply how to do the former so I did the latter, with an inelegant fix:

Text Formatted Code
    if( $_CONF['hideviewscount'] != 1 && str_replace(',', '', $story->DisplayElements('hits')) > 150 && !empty($bodytext) ) {


so it strips out the comma and the result is compared with 150.

But this assumes the user has commas to separate 1000s. That's all we offer on our site, but who knows one day.

Digging around I could see that $story is an instance of a class and it has $_hits in it, but it's a private member and I have no idea how to get at it. I don't want to stuff around with changing your classes, customisations like this are already a hassle to maintan. So I'll probably stick with what I've got unless there is a very simple fix? I guess I could query the database (by copying other examples) to populate $A as required for the original suggestion.
 Quote

All times are EDT. The time is now 03:27 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content