Posts: 5
Threads: 1
Joined: Jan 2019
PHP Code:
<?php
$cmtx_folder = 'upload'; // the name of your Commentics folder
require_once($_SERVER['DOCUMENT_ROOT'] . '/extractor.php');
$extractor = new extractor($cmtx_folder);
if ($extractor->isConnected()) {
$rating = $extractor->pageRating('1'); // $cmtx_identifier, change this to your page identifier
if ($rating == 0) {
echo '<img src="/img/0_star.png" width="102" height="20" title="Нет оценки" alt="Нет оценки">';
} else if ($rating == 1) {
echo '<img src="/img/1_star.png" width="102" height="20" title="Ужасно" alt="1 звезда">';
} else if ($rating == 2) {
echo '<img src="/img/2_star.png" width="102" height="20" title="Плохо" alt="2 звезды">';
} else if ($rating == 3) {
echo '<img src="/img/3_star.png" width="102" height="20" title="Средний" alt="3 звезды">';
} else if ($rating == 4) {
echo '<img src="/img/4_star.png" width="102" height="20" title="Хорошо" alt="4 звезды">';
} else if ($rating == 5) {
echo '<img src="/img/5_star.png" width="102" height="20" title="Отлично" alt="5 звезд">';
}
}
?>
Temporarily solved the problem by displaying images in the .png format
In Commentics v2.4, images were also displayed in this way. In Commentics v3.3, the stars are loaded in the form of font icons Font Awesome. How to display stars using Font Awesome on another page? I do not know yet ...
Posts: 2,895
Threads: 59
Joined: Jun 2010
Sorry for the late reply.
Firstly you want to include Font Awesome if you haven't already:
Code:
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
Then this is to output the stars:
PHP Code:
<?php
for ($i = 0; $i < 5; $i++) {
if ($i < $rating) {
echo '<span class="cmtx_star cmtx_star_full"></span>';
} else {
echo '<span class="cmtx_star cmtx_star_empty"></span>';
}
}
This is the CSS:
Code:
.cmtx_star:before {
font-size: 1.1em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}
.cmtx_star_empty {
color: #DDDDDD;
}
.cmtx_star_full {
color: #FFD700;
}
Have
you completed
the interview?
Posts: 5
Threads: 1
Joined: Jan 2019
Great decision, Steven! Everything works. Thank you! Another small question: how can I add to the conclusion of the title (0 stars - no ratings, 1 star - Terrible, 2 stars - Bad, 3 stars - Average, 4 stars - Good, 5 stars - Excellent)?
Posts: 5
Threads: 1
Joined: Jan 2019
(10-Jan-2019, 10:06 AM)intercomm Wrote: Great decision, Steven! Everything works. Thank you! Another small question: how can I add to the conclusion of the title (0 stars - no ratings, 1 star - Terrible, 2 stars - Bad, 3 stars - Average, 4 stars - Good, 5 stars - Excellent)?
I was a little hasty with the question. I think there is no need to output title. Thanks again for your help, Steven!