2012-10-16 78 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

相关问题