Opencart为类别添加额外的tpl布局

Opencart为类别添加额外的tpl布局,opencart,Opencart,我正在尝试在Opencart 1.5.4中设置其他页面和类别布局 我已经到了一个阶段,如果我在地址栏中输入新类别的路由,新模板会显示我想要的,但我似乎无法在OC中注册路由更改 如果我在.htaccess文件中指定更改,新模板将按预期加载,但我不这么认为,这是解决问题的正确答案(尽管它可以工作) 添加到.htaccess(我确定方法不正确) 我已经创建了两个新文件 /catalog/view/theme/default/template/product/categories.tpl /catalo

我正在尝试在Opencart 1.5.4中设置其他页面和类别布局

我已经到了一个阶段,如果我在地址栏中输入新类别的路由,新模板会显示我想要的,但我似乎无法在OC中注册路由更改

如果我在.htaccess文件中指定更改,新模板将按预期加载,但我不这么认为,这是解决问题的正确答案(尽管它可以工作)

添加到.htaccess(我确定方法不正确)

我已经创建了两个新文件

/catalog/view/theme/default/template/product/categories.tpl
/catalog/controller/product/categories.php
在/catalog/controller/product/categories.php中,我更改了内容以反映新的tpl文件

class Controllerproductcategories extends Controller {

总之是这样的

  • 如果我在.htaccess文件中指定重写,布局将加载,如果我不指定,则不会加载
  • 我在OC中添加了一个新布局,并根据类别选择了它
  • 有人知道我该怎么做吗?我有一个模板负荷创建的产品,类别和信息页,所以想这样做正确

    提前发送


    斯图

    从我看到的情况来看,您试图对每个模板进行硬编码,但实际上无法按照您选择的使用类别布局的方式工作。版面设计用于在页面上排列内容,而不是指定模板


    事实上,我已经创建了一个商业版本,可以找到你想要实现的目标。它允许您创建模板并将其分配给一个或多个页面。它适用于产品、类别、制造商和信息页面。它还允许您为整个类别或制造商下的产品指定模板

    我最终选择了这种方法。。可能会帮助别人

    if ($this->data['heading_title'] == "Skis") {
    
        $this->template = $this->config->get('config_template') . '/template/product/categories.tpl';
    
    } elseif ($this->data['heading_title'] == "Softgoods") {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    } elseif ($this->data['heading_title'] == "Outlet Store") {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    } else {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    }
    

    因此,布局用于OC模块,而不是模板文件的覆盖。啊,太糟糕了。感谢插件上的链接,但我将坚持使用.htaccess方法,我对插件的信心与日俱增,升级、缺乏测试,尤其是大型产品集等。很好,尽管使用switch语句可能比使用其他语句更好
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/categories.tpl')) {
     $this->template = $this->config->get('config_template') . '/template/product/categories.tpl';
    } else {
     $this->template = 'default/template/product/categories.tpl';
    }
    
    if ($this->data['heading_title'] == "Skis") {
    
        $this->template = $this->config->get('config_template') . '/template/product/categories.tpl';
    
    } elseif ($this->data['heading_title'] == "Softgoods") {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    } elseif ($this->data['heading_title'] == "Outlet Store") {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    } else {
    
        $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    
    }