Если делать через сторонний плагин у меня это плагин Like, то получается необходимо:
1. создать правило в AUP - это я сделал.
2. и в каком-то месте файла Like вставить код:
$api_AUP = JPATH_SITE.'/components/com_altauserpoints/helper.php';
if ( file_exists($api_AUP))
{
require_once $api_AUP;
$aupid = AltaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid )
AltaUserPointsHelper::newpoints( 'plgaup_content_like', $aupid );
}
Я пробовал устанавливать в разных местах, но начисление баллов происходит сразу как открывается статья(радует, что начисление уже происходит...).
Вот как выглядит файл плагина Like:
<?php
defined('_JEXEC') or die;
$doc = JFactory::getDocument();
$doc->addStyleDeclaration(".form-like {margin:15px 0!important;}.btn-like {background-color: transparent!important;background-image: none;border-radius: 4px;border: 1px solid #ccc;color: #999;line-height: 18px!important;height: 30px!important;padding: 6px 10px 5px 10px!important;text-shadow:none;box-sizing:border-box;}.btn-like:hover {border-color: #4098d1;}.btn-like img {margin-right: 5px;float: left;}.element-invisible {position: absolute;padding: 0;margin: 0;border: 0;height: 1px;width: 1px;overflow: hidden;}
");
class PlgContentLike extends JPlugin
{
protected $autoloadLanguage = true;
public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
{
$parts = explode(".", $context);
if ($parts[0] != 'com_content')
{
return false;
}
$html = '';
if (!empty($params) && $params->get('show_vote', null))
{
$rating = (int) @$row->rating;
$view = JFactory::getApplication()->input->getString('view', '');
$img = '';
$starImageOn = JHtml::_('image', JURI::root().'plugins/content/like/assets/like_on.png', JText::_('PLG_LIKE_STAR_ACTIVE'), 'width="16"', true);
$starImageOff = JHtml::_('image', JURI::root().'plugins/content/like/assets/like_off.png', JText::_('PLG_LIKE_STAR_INACTIVE'), 'width="16"', true);
if($rating > 1) {
$img .= $starImageOn;
} else {
$img .= $starImageOff;
}
$html .= '<div class="content_rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$html .= '<p class="unseen element-invisible">'
. JText::sprintf('PLG_LIKE_USER_RATING', '<span itemprop="ratingValue">' . $rating . '</span>', '<span itemprop="bestRating">5</span>')
. '<meta itemprop="ratingCount" content="' . (int) $row->rating_count . '" />'
. '<meta itemprop="worstRating" content="0" />'
. '</p>';
$html .= '<>';
if ($view == 'article' && $row->state == 1)
{
$uri = JUri::getInstance();
$uri->setQuery($uri->getQuery(). '&hitcount=0');
Но в какое место вставить этот код, чтобы начисление баллов происходило только после оценки статьи?