Php Opencart在评论中显示船旗国 当顾客离开时,我想向他们展示船旗国

Php Opencart在评论中显示船旗国 当顾客离开时,我想向他们展示船旗国,php,opencart,review,Php,Opencart,Review,我这样做: 在db表格评审中添加了一行,名为country\u id 在catalog/model/catalog/review.php中public function addReview(I添加: ,country\u id='”(int)$this->config->get('config\u country\u id')。“因此,如果用户登录,它将存储用户的country\u id 现在,我如何从image/flag调用它并将图像标志放入review.tpl 这是一个没有人能给出解

我这样做:

  • 在db表格评审中添加了一行,名为
    country\u id
  • catalog/model/catalog/review.php中
    public function addReview(
    I添加:
    • ,country\u id='”(int)$this->config->get('config\u country\u id')。“
      因此,如果用户登录,它将存储用户的
      country\u id
现在,我如何从image/flag调用它并将图像标志放入
review.tpl

这是一个没有人能给出解决方案的话题


有什么帮助吗?

现在您已经存储了
国家/地区id
,您可以在加载评论时基于该id加载具体的国家/地区(分别针对每个评论)

从DB加载审阅时,在方法
review()
中的
catalog/controller/product/product.php
中,结果数组循环通过:

    foreach ($results as $result) {
        $this->data['reviews'][] = array(
            'author'     => $result['author'],
            'text'       => $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']))
        );
    }
现在,您只需加载国家代码即可获得国旗代码,因此您可以得到如下结果:

    $this->load->model('localisation/country');

    foreach ($results as $result) {
        $country = $this->model_localisation_country->getCountry($result['country_id']);

        $this->data['reviews'][] = array(
            'author'     => $result['author'],
            'text'       => $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'])),
            'flag'       => strtolower($country['iso_code_2']) . '.png'
        );
    }
现在,
flag
索引应该包含像
de.png
gb.png
fr.png
等值。只需确保您在模板中为标志图像键入了正确的值,并且您拥有具有此类名称的标志图像