0

我想使用“位置”字段为 opencart 2.0.1.1 创建页面特定的模板文件。我想知道这可以与 seo url 一起使用吗?我在 opencart 2.0.1.1 的 header.php 底部找到了这个

// 对于页面特定的 css

    if (isset($this->request->get['route'])) {
        if (isset($this->request->get['product_id'])) {
            $class = '-' . $this->request->get['product_id'];
        } elseif (isset($this->request->get['path'])) {
            $class = '-' . $this->request->get['path'];
        } elseif (isset($this->request->get['manufacturer_id'])) {
            $class = '-' . $this->request->get['manufacturer_id'];
        } else {
            $class = '';
        }

        $data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
    } else {
        $data['class'] = 'common-home';
    }

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
        return $this->load->view($this->config->get('config_template') . '/template/common/header.tpl', $data);
    } else {
        return $this->load->view('default/template/common/header.tpl', $data);
    }

我相信这只是页面特定 css 的代码结构,我想更改页面特定的 .tpl 文件。我想使用开关控制方法,我会为不同的产品使用至少 5 个模板。下面这个例子来自 opencart 1.5x。将会是完美的

OpenCart - 根据任意产品字段查看替代产品模板

4

1 回答 1

0

花了很长时间,但在这里解决了这个问题是其他人使用“免费”的代码

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_'.$product_id.'.tpl')) {
    $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product_'.$product_id.'.tpl', $data));

} elseif (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
                $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
} else {
    $this->response->setOutput($this->load->view('default/template/product/product.tpl', $data));
}

/* 解释: 1. 代码将根据它的 ID 搜索特定的模板。例如:product_18.tpl。2. 如果特定模板不可用,Opencart 将使用活动主题的通用模板(product.tpl)。3. 如果特定主题的模板不可用,Opencart 将使用默认主题的模板。*/

对于使用产品 tpl 添加 /product_* 的 VQ 模组

于 2015-04-05T10:29:23.657 回答