This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Commentics v3.3 output star rating on another page
#1

Sorry for bad english (machine translation from russian).
Loved your comment system for the site. Thanks for the great job!
I wanted to clarify the possibility of displaying a star rating on another page of the site.
I have already read the description of the output of the star rating (in this forum), but here the description for Commentics v2.4, and in Commentics v3.3 everything is completely different. I am not strong in PHP, so I will be very grateful if you tell me how to implement it. Thanks in advance for any help.
Reply
#2

Hi there,

I suggest using the free Extractor module.

It'd be similar to this:

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 == 1) {
// show one full star
} else if ($rating == 2) {
// show two full stars etc
}
*/
}

Have you completed the interview?
Reply
#3

Thank you very much, Steven, for your prompt reply!

The extractor module is a great solution. I just recently started using Commentics, so I didn’t know about it. I figured out the standard operation of the extractor module, but did not understand how to output stars. What output code to use and where to get it? Example below:



PHP Code:
<?php 
if ($rating == 1) {
// show one full star - What code to use for the output of stars?
} else if ($rating == 2) {
// show two full stars etc - What code to use for the output of stars?
}
Reply
#4

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 ...
Reply
#5

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?
Reply
#6

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)?
Reply
#7

(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!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Seven Thunders
21-Aug-2018, 04:05 AM
Last Post by cecilia
15-Jun-2014, 01:08 AM
Last Post by DuO-VB
21-Mar-2014, 04:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)