如何在Opencart的主类别页面上显示子类别图像?

时间:2018-12-29 13:49:00

标签: php image opencart categories

我有一个Opencart网站,当我单击任何产品类别页面时,我想在其中显示带有缩略图的子类别。

这是我在catalog / controller / product / category.php

中的 foreach($ results为$ result)循环中编辑的代码。
 function remove_extra_in_url($url)
{
    $extra=array('https://','http://','www.',' ');
    $url=strtolower($url);
    $url=str_replace($extra,'',$url);
    $i=0;
    $site_name='';
    $len=strlen($url);
    while($url[$i]!='/' && $url[$i]!='?' && $i<$len)
    {
        $site_name.=$url[$i];
        $i++;
    }
    return $site_name;
}

下面是我在目录/视图/主题/提升/模板/通用中编辑的代码

    if ($result['image'] && file_exists(DIR_IMAGE.$result['image'])) {
        $thumb = $this->model_tool_image->resize(DIR_IMAGE.$result['image'], 100, 100);
    } else {
        $thumb = $this->model_tool_image->resize(DIR_IMAGE.'placeholder.png', 100, 100);
    }

    $data['categories'][] = array(
        'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
        'thumb' = $thumb,
        'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url));

但是图像仍然没有显示。似乎是什么问题?请帮助

1 个答案:

答案 0 :(得分:0)

我看到的唯一问题是您在数组中写了=而不是=>。

$data['categories'][] = array(
    ...
    'thumb' = $thumb,

应该是

$data['categories'][] = array(
    ...
    'thumb' => $thumb,

如果这只是一个拼写错误,而您仍然看不到渲染的图像,请尝试以下操作:

  1. 清除树枝缓存(此处为http://joxi.ru/YmEaw4LUwM67Nm
  2. 检查您的system / storage / modification文件夹,以检查您是否没有缓存的控制器或树枝视图文件的修改文件。
相关问题