I have coded and tested this feature with success. This enables the admin configuration for articles to exclude (do not count) front-end views (hits) on articles by users belonging to the specified groups.
Hope it helps
Simple changes only need to be implemented in the following scripts:
administrator/components/com_content/config.xml I've done the following:
<field name="count_hits"
type="UserGroup"
multiple="true"
size="20"
label="COM_CONTENT_DISABLE_HIT_COUNT_LABEL"
description="COM_CONTENT_DISABLE_HIT_COUNT_DESC"/>
and in
components/com_content/views/article/view.html.php I've done the following:
Changes near line 138
// Increment the hit counter of the article.
$groups = $user->getAuthorisedGroups();
if(!$this->params->get('intro_only') && $offset == 0 && $this->countHits($groups) == true) {
Added new method near line 155
/**
* Checks if user is within the groups that should'nt increase the articles' hits
*
* @param $groups Array containing the groups to exclude
* @return bool Returns false (don't count) if user in selected groups
*/
private function countHits($groups)
{
$countHits = true;
$count = $this->params->get('count_hits', false);
if($groups && $count) {
for ($n = 0, $i = count($groups); $n < $i; $n++) {
if(in_array($groups[$n], $count)) {
// User is in the group
$countHits = false;
}
}
}
return $countHits;
}
in administrator/language/en-GB/en-GB.com_content.ini needs just a couple lines added:
COM_CONTENT_DISABLE_HIT_COUNT_LABEL="Disbale hit count"
COM_CONTENT_DISABLE_HIT_COUNT_DESC="Select the user group or groups that will not increment the article hits in the front-end."