2016-11-18 181 views

回答

0

已解決。 有人可以派上用場。

在文件\目錄\控制器\產品\ category.php

替換代碼:

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

要這樣:

$template = 'category.tpl'; 
     if ($category_id == 72) { $template = 'category-72.tpl'; } 

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

取而代之的是72把你的類別ID。

創建模板我們這裏類別:

\目錄\視圖\主題\ NAME_THEME \模板\產品\類別的72.tpl

然後去管理員 - >模塊 - >修改器並更新緩存。完成。

+0

我認爲現在我明白你了,這裏有一個類似的問題:http://stackoverflow.com/questions/40755573/specific-template-for-category-and-product-page-in-opencart-2-2-0-0/40763592 #40763592 – DigitCart

+0

是的。謝謝) –

0

在Opencart的2,body如果你是在一個類別都有相關class頁面您正在查看,例如,bodyclass應是:

<body class="product-category-20"> 

您可以使用它像這樣:

body.product-category-20 { 
    background-color: red; 
} 

而對於另外一類;

body.product-category-21 { 
    background-color: green; 
} 

對於分配不同的模塊,每個類別中,您可以添加一個新的佈局,然後選擇設計選項卡此佈局,當你編輯或創建一個新的類別。

+0

在目錄/content/view/theme/myTheme/template/product/nameTemplate.tpl 中創建的佈局模板和網站的管理部分在菜單佈局中創建了一個佈局,但是當連接到該類別時,發生變化... 我做的一切都對嗎? –

+0

不,您不需要創建其他文件。看看這篇精美的文章:https://forum.opencart.com/viewtopic.php?f=138&t=37119 – DigitCart

+0

也許你誤會了我,我的意思是每個類別都有自己獨特的設計,也就是說,我有一個設計(_layout_ ),並需要在該類別中顯示它。可能嗎? –

相關問題