Редактор темы

Реклама
Реклама
Реклама
Реклама

Общий оценка в рейтинге с 10 зведами

never3d22

Забанен
Регистрация
3 Дек 2015
Сообщения
1.014
Рейтинг реакций
100
Баллы
63
1/3
Автор темы
Есть код вывода рейтинга 10 зведами, как вывести общую оценку звезд в другом месте fullstory?
Код:
function ShowRating($id, $rating, $vote_num, $allow = true) {
    global $lang, $config;

    if( !$config['rating_type'] ) {
       
        if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 1 );
    else $rating = 0;
    $rating1 = str_replace( ",", " . ", $rating );
    $rating2 = $rating1 * 10;
   
        if( ! $allow ) {
       
        $rated = <<<HTML
<div class="rating">
        <ul class="unit-rating">
        <li class="current-rating" style="width:{$rating2}%;">{$rating2}</li>
        </ul>
        {$vote_num}
</div>
HTML;
       
        return $rated;
    }
   
        $rated .= <<<HTML
<div id='ratig-layer-{$id}'><div class="rating">
        <ul class="unit-rating">
        <li class="current-rating" style="width:{$rating2}%;">{$rating2}</li>
        <li><a href="#" title="1" class="r1-unit" onclick="doRate('1', '{$id}'); return false;">1</a></li>
        <li><a href="#" title="2" class="r2-unit" onclick="doRate('2', '{$id}'); return false;">2</a></li>
        <li><a href="#" title="3" class="r3-unit" onclick="doRate('3', '{$id}'); return false;">3</a></li>
        <li><a href="#" title="4" class="r4-unit" onclick="doRate('4', '{$id}'); return false;">4</a></li>
        <li><a href="#" title="5" class="r5-unit" onclick="doRate('5', '{$id}'); return false;">5</a></li>
        <li><a href="#" title="6" class="r6-unit" onclick="doRate('6', '{$id}'); return false;">6</a></li>
        <li><a href="#" title="7" class="r7-unit" onclick="doRate('7', '{$id}'); return false;">7</a></li>
        <li><a href="#" title="8" class="r8-unit" onclick="doRate('8', '{$id}'); return false;">8</a></li>
        <li><a href="#" title="9" class="r9-unit" onclick="doRate('9', '{$id}'); return false;">9</a></li>
        <li><a href="#" title="10" class="r10-unit" onclick="doRate('10', '{$id}'); return false;">10</a></li>
        </ul>
       
</div></div>
HTML;
   
        return $rated;

    }
}
 
Открыть /engine/modules/show.full.php найти :
PHP:
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
ниже вставить :
PHP:
$tpl->set( '{rating_result}', isset($row['vote_num']) ? str_replace(",", " . ", round( ($row['rating'] / $row['vote_num']), 1 ) ) : 0);
Далее найти :
PHP:
$tpl->set( '{rating}', "" );
ниже вставить :
PHP:
$tpl->set( '{rating_result}', "");
 
Автор темы
Открыть /engine/modules/show.full.php найти :
PHP:
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
ниже вставить :
PHP:
$tpl->set( '{rating_result}', isset($row['vote_num']) ? str_replace(",", " . ", round( ($row['rating'] / $row['vote_num']), 1 ) ) : 0);
Далее найти :
PHP:
$tpl->set( '{rating}', "" );
ниже вставить :
PHP:
$tpl->set( '{rating_result}', "");
спасибо чувак
 
Автор темы
а в show custom этот код работаь будет?
 
Автор темы
не работает, вот фрагмент кода
Код:
    if( $row['allow_rate'] ) {
           
        if( $config['short_rating'] AND $user_group[$member_id['user_group']]['allow_rating'] ) {
               
            $tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], 1 ) );
            $tpl->set( '{bad_rating}', ShowRating( $row['id'], $row['m_rate'], $row['m_vote'], 1, true ) );   
            if ( $config['rating_type'] ) {
                   
                $tpl->set( '[rating-plus]', "<a href=\"#\" onclick=\"doRate('plus', '{$row['id']}'); return false;\" class=\"like\" >" );
                $tpl->set( '[/rating-plus]', '</a>' );
               
                if ( $config['rating_type'] == "2" ) {
                   
                    $tpl->set( '[rating-minus]', "<a href=\"#\" onclick=\"doRate('minus', '{$row['id']}'); return false;\" class=\"unlike\" >" );
                    $tpl->set( '[/rating-minus]', '</a>' );
                   
                } else {
                    $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
                }
               
            } else {
                $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
                $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
            }
           
        } else {
           
            $tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], 0 ) );
            $tpl->set( '{rating_result}', isset($row['vote_num']) ? str_replace(",", " . ", round( ($row['rating'] / $row['vote_num']), 1 ) ) : 0);
            $tpl->set( '{bad_rating}', ShowRating( $row['id'], $row['m_rate'], $row['m_vote'], 0, true ) );
            $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
            $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
        }

        $tpl->set( '{vote-num}', "<span id=\"vote-num-id-".$row['id']."\" class=\"ignore-select\">".$row['vote_num']."</span>" );
        $tpl->set( '{bad-vote-num}', "<span id=\"bad_vote-num-id-".$row['id']."\" class=\"ignore-select\">".$row['m_vote']."</span>" );
        $tpl->set( '[rating]', "" );
        $tpl->set( '[/rating]', "" );
       
    } else {
       
        $tpl->set( '{rating}', "" );
        $tpl->set( '{rating_result}', "");
        $tpl->set( '{bad_rating}', "" ); $tpl->set( '{bad-vote-num}', "" );
        $tpl->set( '{vote-num}', "" );
        $tpl->set_block( "'\\[rating\\](.*?)\\[/rating\\]'si", "" );
        $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
        $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
    }
 
да чистил кэш не работает
Еще после
PHP:
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], 1 ) );
вставить :
PHP:
$tpl->set( '{rating_result}', isset($row['vote_num']) ? str_replace(",", " . ", round( ($row['rating'] / $row['vote_num']), 1 ) ) : 0);
 

Похожие темы Последние темы Популярные темы

Назад
Сверху