A happy OpenCart developer from Brighton.
Possible to replacing all with plain html, BUT your form to submit reviews would not work.
To load the reviews into the DOM, you'll likely need to rewrite it a bit to merge the review callback to be triggered during the main page load and then merge the tpl into the product.tpl. It's not necessarily difficult but tedious and if you are not familiar with the code you may need to hire someone ( ) to do it.
A happy OpenCart developer from Brighton.
Anyway I'll try your solution "countzer0" but can you please be a little more specific? Maybe step by step explanation? Because I'm not good with php at all.
Thank you.
Here's the vqmod I used:
Code: Select all
<modification>
<id>Make User Reviews Indexable</id>
<version>1.0.0</version>
<vqmver>2.1</vqmver>
<author>countzer0</author>
<file name="catalog/controller/product/product.php">
<operation>
<search position="before"><![CDATA[$this->data['tags'] = array();]]></search>
<add><![CDATA[ $this->data['reviews'] = array();
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], 0, 20);
foreach ($results as $result) {
$this->data['reviews'][] = array(
'author' => $result['author'],
'text' => strip_tags($result['text']),
'rating' => (int)$result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total),
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
]]></add>
</operation>
</file>
<file name="catalog/view/theme/default/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[<div id="review"></div>]]></search>
<add><![CDATA[ <div id="review">
<?php if ($reviews) { ?>
<?php foreach ($reviews as $review) { ?>
<div class="content"><b><?php echo $review['author']; ?></b> | <img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="<?php echo $review['reviews']; ?>" /><br />
<?php echo $review['date_added']; ?><br />
<br />
<?php echo $review['text']; ?></div>
<?php } ?>
<?php } else { ?>
<div class="content"><?php echo $text_no_reviews; ?></div>
<?php } ?>
</div>
]]></add>
</operation>
</file>
</modification>
This solution is a bit of a hack - it places the review text in the HTML while leaving the AJAX code untouched. In other words, the review text is pulled in twice, but this doesn't seem to affect the appearance of the page.
A happy OpenCart developer from Brighton.
STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/
Code: Select all
<file name="catalog/view/theme/default/template/product/product.tpl">
A happy OpenCart developer from Brighton.
Thanks for the quick reply.
STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/
A happy OpenCart developer from Brighton.
So how does one do that exactly? And where? Is it a code addition, replacement? That looks a bit more challenging for my skill level
STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/
A happy OpenCart developer from Brighton.
UPDATE: That did the trick! Thanks again mate!
STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/
However, for some reason the review link just below the add to cart button now says "Array" instead of the number of reviews. The reviews tab seems to be working correctly (number of reviews shown correctly here) and the review is loaded into the HTML but I wonder what is causing this link to be labelled incorrectly?
Also, countzer0 mentioned that this mod is a bit of a "hack" and that the original AJAX code is left untouched. Is there a way to remove the AJAX code and still have this function correctly?
Code: Select all
<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $reviews; ?></a>
A happy OpenCart developer from Brighton.
Yes, that is exactly how it appears in the product template file currently in use. Is there something that should be changed here?countzer0 wrote:Is it the same in your code?
Also, would you (or anyone else) have any further suggestions on how to eliminate Ajax completely (eliminating the need to pull in the review data twice)?
To be honest, I am a little surprised that this wasn't considered for the core code. User reviews are definitely beneficial to SEO (especially after the most recent algorithm update) and it is a shame that we have to implement a hack just to have this content indexed.
Code: Select all
<modification>
<id>Make User Reviews Indexable</id>
<version>1.0.0</version>
<vqmver>2.1</vqmver>
<author>countzer0</author>
<file name="catalog/controller/product/product.php">
<operation>
<search position="before"><![CDATA[$this->data['tags'] = array();]]></search>
<add><![CDATA[ $this->data['reviews_array'] = array();
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], 0, 20);
foreach ($results as $result) {
$this->data['reviews_array'][] = array(
'author' => $result['author'],
'text' => strip_tags($result['text']),
'rating' => (int)$result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total),
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
]]></add>
</operation>
</file>
<file name="catalog/view/theme/default/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[<div id="review"></div>]]></search>
<add><![CDATA[ <div id="review">
<?php if ($reviews_array) { ?>
<?php foreach ($reviews_array as $review) { ?>
<div class="content"><b><?php echo $review['author']; ?></b> | <img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="<?php echo $review['reviews']; ?>" /><br />
<?php echo $review['date_added']; ?><br />
<br />
<?php echo $review['text']; ?></div>
<?php } ?>
<?php } else { ?>
<div class="content"></div>
<?php } ?>
</div>
]]></add>
</operation>
</file>
</modification>
A happy OpenCart developer from Brighton.
By the way, I noticed that the image alt tag for the star rating was referencing the text for the number of ratings (eg: 2 Reviews). I thought this was a little odd as alt text is meant to describe the image.
So I changed this...
Code: Select all
<img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="<?php echo $review['reviews']; ?>" />
Code: Select all
<img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="Rating: <?php echo $review['rating']; ?>" />
I might even attempt to modify the code in such a way to achieve valid rich snippets markup as outlined here: http://support.google.com/webmasters/bi ... wer=146645
It would be great to see the user review ratings appear as rich snippets in search results. Might be easier said than done though.
Users browsing this forum: No registered users and 63 guests