Thursday, 11 February 2021 16:15

Automatically Hide Article Count for Articles with Low Traffic

Written by 
Automatically Hide Article Count for Articles with Low Traffic

Deciding whether or not to show the number of or "hits" or "views" that an article has received is easy with Joomla: you toggle them globally, and on a per-article basis. So if you have an blog with relatively low traffic, but you have a popular article where you want to show how a hit counter, it's easy: disable the view count globally and enable it for the individual article.

After a while, this starts to get old, because you generally post an article without the hit counter showing and then if it gets a lot of traffic, you want to turn it on.

With this in mind I decided to write a quick custom script.

The original code looks something like this:

<?php if($this->item->params->get('itemHits')): ?>

 

 

The new code:

<?php 
// declare new "hit" variable
$c2hits=$this->item->hits;
?>

<?php if($this->item->params->get('itemHits') && $c2hits > 100): ?>
Read 74 times Last modified on Thursday, 11 February 2021 16:22

Comments (0)

There are no comments posted here yet

Leave your comments

  1. Posting comment as a guest.
Attachments (0 / 3)
Share Your Location