Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 11:15 am EDT

Geeklog Forums

Hide 'Viewed' x times if no body text


tokyoahead

Anonymous
artistic
Hi,

The Problem: Articles with no body text still display the "Viewed x times", which is then normally 0. This makes the article look uninteresting. So This hack removes the "Viewed x times" for all articles that have no bodytext, if the respective flag is set in the config.php (see below). You can see how it works on my page at the topic "General" here.

After requesting this I decided to write it myself now:

1. Add the following line to your config.php:

Text Formatted Code
$_CONF['show_views_where_no_bodytext'] = 0;

 


then, open your lib_common.php and search for (around line 403 in the function COM_article:

Text Formatted Code
$article->set_var( 'story_hits', $A['hits']);

 


then replace this line by:

Text Formatted Code

if ( ($_CONF['show_views_where_no_bodytext'] == 1) or (!empty($A['bodytext'])))
{
$article->set_var( 'story_hits', 'Viewed: ' . $A['hits'] . ' times' );
}


 


then, open your template folder and edit both files featuredstorytext.thtml and storytext.thtml. There, remove the "Viewed:" and "times", since the {story_hits} will include that text now.

Now, you wont see a disappointing "Viewed 0 times" for an article that cannot be viewed at all!

good luck hacking!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by tokyoahead: Now, you wont see a disappointing "Viewed 0 times" for an article that cannot be viewed at all!

Of course it can be viewed - from the RSS feed, from a search result, from the older stories block (once it's moved there), from a link in the daily digest or from a link in an email (if you emailed the story to someone), etc.

It could be argued that the story should be counted as being "viewed" on the index page (as the entire story is displayed there), but I'm afraid that the additional SQL requests needed to accomplish this would slow down things more than this is worth ...

bye, Dirk
 Quote

tokyoahead

Anonymous
Quote by Dirk:Of course it can be viewed


you are right, I did not think about those options you mentioned. However I think its then the best option to leave it as a setting in the config. since switched off all the options you named, I think its a good idea to just hide it... there cold be a text in the config.php that exlpains the issues of this matter and leaves the choice to the user.

I also agree with you on the index page issue. Finally stories without body text are in a different class, since they are often only short announcements and it does not really matter sometimes.

Maybe it would be the best to have a setting in the story options to hide the counter for each story individually? what do you thin about that?

Oliver
 Quote

All times are EDT. The time is now 11:15 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