Skip to content

Commit

Permalink
Option to disable save article hits
Browse files Browse the repository at this point in the history
  • Loading branch information
Juri Hahn committed Sep 27, 2018
1 parent c31ff51 commit 6ef8ba7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions administrator/components/com_content/config.xml
Expand Up @@ -350,6 +350,18 @@
<option value="0">JHIDE</option>
</field>

<field
name="save_hits"
type="radio"
label="COM_CONTENT_FIELD_SAVEHITS_LABEL"
description="COM_CONTENT_FIELD_SAVEHITS_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="show_noauth"
type="radio"
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_content.ini
Expand Up @@ -90,6 +90,8 @@ COM_CONTENT_FIELD_PUBLISH_DOWN_DESC="An optional date to Finish Publishing the a
COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL="Finish Publishing"
COM_CONTENT_FIELD_PUBLISH_UP_DESC="An optional date to Start Publishing the article."
COM_CONTENT_FIELD_PUBLISH_UP_LABEL="Start Publishing"
COM_CONTENT_FIELD_SAVEHITS_DESC="If you want to display the hits, then select YES to save the number hits."
COM_CONTENT_FIELD_SAVEHITS_LABEL="Save Hits"
COM_CONTENT_FIELD_SELECT_ARTICLE_DESC="Select or create an article to be displayed."
COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL="Select Article"
COM_CONTENT_FIELD_SHOW_CAT_TAGS_DESC="Show the tags for the category."
Expand Down
8 changes: 7 additions & 1 deletion components/com_content/controller.php
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;

/**
* Content Component Controller
*
Expand Down Expand Up @@ -106,7 +108,11 @@ public function display($cachable = false, $urlparams = false)
// Get/Create the model
if ($model = $this->getModel($vName))
{
$model->hit();
$config = ComponentHelper::getParams('com_content');
if ($config->get('save_hits', 1) == 1)
{
$model->hit();
}
}
}

Expand Down

0 comments on commit 6ef8ba7

Please sign in to comment.