Skip to content

Commit

Permalink
Option to stop robots inc banners views (#22339)
Browse files Browse the repository at this point in the history
* do not increment impress/views of banners if robot detected

* Option for BC by default

* Sort keys in alpha order

* quotes for parameter name

* Wording

* wording

* wording

* Option for ignoring robots moved to com_banners

* Codestyle

* Better wording

* sort keys

* wording

* wording
  • Loading branch information
jurihahn authored and Michael Babker committed Dec 27, 2018
1 parent 53d72b9 commit 63d39cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions administrator/components/com_banners/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
<option value="0">JNO</option>
</field>

<field
name="track_robots_impressions"
type="radio"
label="COM_BANNERS_FIELD_TRACKROBOTSIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKROBOTSIMPRESSION_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="track_clicks"
type="radio"
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_banners.ini
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ COM_BANNERS_FIELD_TRACKCLICK_DESC="Record the number of clicks on the banners on
COM_BANNERS_FIELD_TRACKCLICK_LABEL="Track Clicks"
COM_BANNERS_FIELD_TRACKIMPRESSION_DESC="Record the impressions (views) of the banners on a daily basis."
COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL="Track Impressions"
COM_BANNERS_FIELD_TRACKROBOTSIMPRESSION_DESC="Include search engines in the count of impressions."
COM_BANNERS_FIELD_TRACKROBOTSIMPRESSION_LABEL="Impressions by Search Engines"
COM_BANNERS_FIELD_TYPE_DESC="Choose the type of banner. Select Image to display an image. Select Custom to enter your custom code."
COM_BANNERS_FIELD_TYPE_LABEL="Type"
; The following five strings are deprecated and will be removed with 4.0. They generate wrong plural detection in Crowdin.
Expand Down
9 changes: 8 additions & 1 deletion modules/mod_banners/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Environment\Browser;

/**
* Helper for mod_banners
*
Expand All @@ -30,6 +33,7 @@ public static function &getList(&$params)
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$keywords = explode(',', $document->getMetaData('keywords'));
$config = ComponentHelper::getParams('com_banners');

$model = JModelLegacy::getInstance('Banners', 'BannersModel', array('ignore_request' => true));
$model->setState('filter.client_id', (int) $params->get('cid'));
Expand All @@ -45,7 +49,10 @@ public static function &getList(&$params)

if ($banners)
{
$model->impress();
if ($config->get('track_robots_impressions', 1) == 1 || !Browser::getInstance()->isRobot())
{
$model->impress();
}
}

return $banners;
Expand Down

0 comments on commit 63d39cf

Please sign in to comment.