2012-10-16 90 views
2

我想在產品描述頁面上顯示貨幣列表。我怎樣才能做到這一點?如何讓貨幣在opencart的產品頁面上顯示?

我複製從header.tpl()中的代碼,並在product.tpl粘貼,但我得到一個錯誤:用C幣種:

說明:未定義可變\ XAMPP \ htdocs中\ mysite.com \目錄\視圖\主題\ mytheme \模板\產品\ product.tpl在線60.

我試着在product.tpl中添加下面的代碼。

<?php include(DIR_APPLICATION.'\view\theme\mytheme\template\module\currency.tpl'); 

但這也沒有工作。請幫助,因爲我想得到這個工作。

+0

呼應它向我們展示了** **代碼...的*碼* – 2012-12-13 16:54:28

回答

0

$ currency變量由/catalog/controller/module/currency.php控制器構建,該控制器通常由/catalog/controller/common/header.php(使用$ this-> children數組)調用。

要在產品模板中顯示此元素,您需要使用產品控制器的$ this-> children數組調用此控制器(及其視圖)(/catalog/controller/product/product.php )。在Opencart的1.5.4.1,它的周圍線362

$this->children = array(
    'common/column_left', 
    'common/column_right', 
    'common/content_top', 
    'common/content_bottom', 
    'common/footer', 
    'common/header', 
    'module/currency' // Just add this line 
); 

不幸的是,這將在默認情況下,頁面的頂部顯示貨幣元素,因爲該元素的樣式設置爲絕對定位。您需要編輯/catalog/view/theme/*/template/module/currency.tpl以使HTML和CSS更加靈活。

1

最好將執行此

$this->load->model('localisation/currency'); 
$this->data['allcurrencies'] = array(); 
$results = $this->model_localisation_currency->getCurrencies(); 
foreach ($results as $result) { 
    if ($result['status']) { 
      $this->data['allcurrencies'][] = array(
      'title'  => $result['title'], 
      'code'   => $result['code'], 
      'symbol_left' => $result['symbol_left'], 
      'symbol_right' => $result['symbol_right']    
     ); 
    } 
} 

感謝等

2

控制器/通用/ header.php文件功能指數()中添加:

 $this->data['mygetcurrency'] = $this->currency->getCode(); 

目錄\視圖\ theme \ default \ template \ common \ header.tpl添加到:

 <?php echo $mygetcurrency; ?> 
     //EUR 
0

我想這可能是最簡單的方法。

<?php echo $this->currency->getSymbolRight($this->session->data['currency']) ?> 

OR

<?php echo $this->currency->getSymbolLeft($this->session->data['currency']) ?> 
0

可以使用非常簡單的代碼。將其添加到您的控制器文件中。

$data['currency-symbol'] = $this->currency->getSymbolLeft($this->session->data['currency']); 

現在你可以在你的相關.tpl文件中使用此

<?php echo $currency-symbol ;?> 
+0

有關產品頁面級控制器文件product.php和.tpl文件是product.tpl。上面代碼的 – Pavan

+0

適用於左側符號,例如($ 22或$ 33),對於右側符號(34 $),在'getSymbolLeft'處使用'getSymbolRight'。 – Pavan

相關問題