2011-10-18 80 views
0

我正在使用opencart開源電子商務網站。我遇到的主要問題是,當我嘗試將麪包屑分離成每個.tpl文件中包含的單個文件時。我曾嘗試使用基本的PHP包含方法,雖然這不起作用。Opencart - 在.tpl中包含.tpl

在回覆周杰倫的回答是:

我創建了一個新的麪包屑控制器,使得獨立的麪包屑模板文件。

<?php
class ControllerCommonBreadcrumb extends Controller {

public function index() { 


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

     $this->render(); 
    } 
} 
?> 

雖然這將導致錯誤:

Notice: Undefined variable: breadcrumbs 

回答

1

要做到這一點,你需要首先設置麪包屑模板使用$這個 - >兒童控制器動作的孩子,然後用這種方式迴應麪包屑。您還需要設置麪包屑器的ID,讓你知道在你的模板呼應

我個人只是麪包屑添加到普通/ header.tpl文件代替,所以可以非常容易

+0

謝謝傑伊,我想我理解正確。 –