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

Moving of the stars to the different place of the same page
#1

Dear Commentics Team,
First I want to express my compliments for this wonderful rating system, the most detailed, complex and easy to use that I have seen.

I have a little question:
Is it possible to remove only the rich snippets stars from the basic PHP block and move it to the top of the same page, as a single object?
Please see the image for reference.


Attached Files Thumbnail(s)
   
Reply
#2

Hi,

I'm pleased you like the script!

It's not really possible to "move it" but what you could do is disable the average rating in Layout -> Comments -> Enabled and then add some code to the part of the page where you want it to display.

I think this thread is very similar to what you're wanting to do: http://www.commentics.org/forum/showthre...84#pid4884

Have you completed the interview?
Reply
#3

I added the following code on my product page. The stars appeared, but with the same value in every page (5 von 5 and 1 vote). I think that there is not properly connection with the database.

PHP Code:
<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">

<
span itemprop="itemreviewed">Item</span><br/>
<
span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">
<?
php
$cmtx_identifier
= $_GET['product'];
$cmtx_path = 'rev/';
require_once
$cmtx_path . 'includes/db/connect.php';

$cmtx_identifier = mysqli_real_escape_string($cmtx_link, $cmtx_identifier);

$result = mysqli_query($cmtx_link, "SELECT AVG(`rating`)
FROM (
SELECT `rating` FROM `"
. $cmtx_mysql_table_prefix . "comments` WHERE `is_approved` = '1' AND `rating` != '0' AND `page_id` = '$id'
UNION ALL
SELECT `rating` FROM `"
. $cmtx_mysql_table_prefix . "ratings` WHERE `page_id` = '$id'
)
AS `average`
"
);

$votes = mysqli_num_rows($result);

$average = mysqli_fetch_assoc($result);

$average = $average["AVG(`rating`)"];

$average = round($average, 0);

if (
$average == 1) {
echo
'<img src="/rev/images/stars/star_full.png"><span itemprop="average">1</span> von <span itemprop="best">5</span></span>';
} elseif (
$average == 2) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">2</span> von <span itemprop="best">5</span></span>';
} elseif (
$average == 3) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">3</span> von <span itemprop="best">5</span></span>';
} elseif (
$average == 4) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">4</span> von <span itemprop="best">5</span></span>';
} else {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">5</span> von <span itemprop="best">5</span></span>';
}
?>
<br/>
<span itemprop="votes"><?php echo $votes; ?></span>
</div>
Reply
#4


Have you completed the interview?
Reply
#5

Are you integrating with Magento? If so, if you have the time, could you post in the Tutorials section of the forum saying how you did it?

Have you completed the interview?
Reply
#6

Reply
#7

If you go to this page, scroll down to the very bottom and in the 'Select Store' drop-down field select the Modern Theme. To me it looks identical to the image you attached.

Have you completed the interview?
Reply
#8


Have you completed the interview?
Reply
#9


Have you completed the interview?
Reply
#10

You are right, the image is from Magento Modern Theme. But I use it only to clearly illustrate my intentions. This is not print screen from my website.

I've added error reporting codes, but there is no errors displayed.
Also I've added the following code at the bottom: var_dump($average);

Please, see the attachments.
Image 001 shows what happens on the page with 2 posted comments.
Image 002 shows what happens on the page with 0 posted comments.

The result is the same, only average rating has changed.

I used the following code
PHP Code:
<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">
<
span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">
<?
php
@error_reporting(-1);
@
ini_set('display_errors', 1);

$cmtx_identifier = $_GET['id'];
$cmtx_path = 'rev/';
require_once
$cmtx_path . 'includes/db/connect.php';

$cmtx_identifier = mysqli_real_escape_string($cmtx_link, $cmtx_identifier);

$page_query = mysqli_query($cmtx_link, "SELECT `id` FROM `" . $cmtx_mysql_table_prefix . "pages` WHERE `identifier` = '" . $cmtx_identifier . "'");
$page = mysqli_fetch_assoc($page_query);
$id = $page['id'];

$result = mysqli_query($cmtx_link, "SELECT AVG(`rating`)
FROM (
SELECT `rating` FROM `"
. $cmtx_mysql_table_prefix . "comments` WHERE `is_approved` = '1' AND `rating` != '0' AND `page_id` = '$id'
UNION ALL
SELECT `rating` FROM `"
. $cmtx_mysql_table_prefix . "ratings` WHERE `page_id` = '$id'
)
AS `average`
"
);

$votes = mysqli_num_rows($result);

$average = mysqli_fetch_assoc($result);

$average = $average["AVG(`rating`)"];

$average = round($average, 0);

if (
$average == 1) {
echo
'<img src="/rev/images/stars/star_full.png"><span itemprop="average">1</span>/<span itemprop="best">5</span></span>';
} elseif (
$average == 2) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">2</span>/<span itemprop="best">5</span></span>';
} elseif (
$average == 3) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">3</span>/<span itemprop="best">5</span></span>';
} elseif (
$average == 4) {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">4</span>/<span itemprop="best">5</span></span>';
} else {
echo
'<img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><img src="/rev/images/stars/star_full.png"><span itemprop="average">5</span>/<span itemprop="best">5</span></span>';
}
var_dump($average);
?>
<br/>
<span itemprop="votes"><?php echo $votes; ?></span>
</div>


Attached Files Thumbnail(s)
       
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Seven Thunders
20-Jun-2019, 03:56 AM
Last Post by DuO-VB
21-Mar-2014, 04:26 PM
Last Post by Steven
01-Feb-2013, 03:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)