自定义标题到Opencart信息页面

时间:2014-11-27 11:24:30

标签: opencart

我正在尝试在Open Cart中创建具有特定标题的自定义信息页面。我使用header.php

中的这段代码完成了这项工作
if (!isset($this->request->get['route']) 
    || (isset($this->request->get['route']) 
    && ($this->request->get['route'] == 'information/information')))  {
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_pro.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/common/header_pro.tpl';
} else {
    $this->template = 'default/template/common/header_pro.tpl';
}} 

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

现在我要做的是选择几个我想要分配给header_pro.tpl的信息页面 任何想法如何做到这一点?我一直在努力解决这个问题,提前谢谢你!

1 个答案:

答案 0 :(得分:0)

首先,由于您需要检查路线是否为information/information,因此必须设置 ,因此您只需要此

if (isset($this->request->get['route']) 
    && ($this->request->get['route'] == 'information/information')))  {

现在还要查看具体的信息页面,只记下他们的ID,并添加这个条件

if (in_array($this->request->get['information_id'], array(1, 2, 3, 45, 49))) {
    // display header_pro.tpl
}

所以让它一下子看起来像:

if (isset($this->request->get['route']) 
    && $this->request->get['route'] == 'information/information'
    && in_array($this->request->get['information_id'], array(1, 2, 3, 45, 49)))  {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_pro.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header_pro.tpl';
    } else {
        $this->template = 'default/template/common/header_pro.tpl';
    }
} else {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
    } else {
        $this->template = 'default/template/common/header.tpl';
    }
}