I would ask for some help as its bugging me now. I am trying to rework the REVIEW section of opencart and make it as a module so i can display it whatever I want and also to display a number of reviews which i set as limit from the admin panel. I don't want to be dependend of the product anymore.
Everything at the backend modifications works fine and i can install the module edit it and so on.
Ot the CATALOG side on the other hand the things are different.
Here is my code of the different files at CATALOG side:
catalog/controller/extension/module/review.php
Code: Select all
<?php
class ControllerExtensionModuleReview extends Controller {
public function index($setting) {
$this->load->language('extension/module/review');
$this->load->model('catalog/product');
$data['reviews'] = array();
$results = $this->model_catalog_product->getReviews($setting['limit']);
if ($results) {
foreach ($results as $result) {
$data['reviews'][] = array(
'review_id' => $result['review_id'],
'author' => $result['author'],
'text' => $result['text'],
'rating' => $result['rating'],
'date_added' => $result['date_added']
);
}
return $this->load->view('extension/module/review', $data);
}
}
}
catalog/model/catalog/product.php
Code: Select all
public function getReviews($limit) {
$review_data = array();
$reviews_results_query = $this->db->query("SELECT r.review_id, r.author, r.rating, r.text, r.date_added FROM " . DB_PREFIX . "review r WHERE r.status = '1' ORDER BY r.date_added DESC LIMIT " . (int)$limit);
foreach ($reviews_results_query->rows as $review_result) {
$review_data[] = array(
'review_id' => $review_result['review_id'],
'author' => $review_result['author'],
'text' => $review_result['text'],
'rating' => $review_result['rating'],
'date_added' => $review_result['date_added']
);
}
return $review_data;
}
and the last but not least is the VIEW twig file
catalog/view/theme/my_theme/extension/module/review.twig
Code: Select all
<div class="list-group">
<h3 class="ListTitle">Reviews</h3>
<div class="row">
{% if review %}
{% for review in reviews %}
<table class="table table-striped table-bordered">
<tr>
<td style="width: 50%;"><strong>{{ review.author }}</strong></td>
<td class="text-right">{{ review.date_added }}</td>
</tr>
<tr>
<td colspan="2"><p>{{ review.text }}</p>
{% for i in 1..5 %}
{% if review.rating < i %} <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span> {% else %} <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span> {% endif %}
{% endfor %}</td>
</tr>
</table>
{% endfor %}
{% else %}
<p>No Reviews</p>
{% endif %}
</div>
</div>
Almost forgot to say what the promlem is.
When I add the module say to column right in layout/product for example page becomes blank, it loads the url and everything but white screen.
Thank you in advance