代码之家  ›  专栏  ›  技术社区  ›  Tian Bo

更改货币选择器在Magento中的位置

  •  1
  • Tian Bo  · 技术社区  · 17 年前

    目前,货币选择器位于顶部,这是我的开发站点:

    http://nordschleife.metaforix.net/118/118/index.php/kyocera.html

    但是,我想将货币选择器切换到表的价格标题下。

    echo $this->getCurrency();
    

    getCurrencyHtml() ,但似乎没有这样的方法。

    或者我必须编辑布局文件,我应该怎么做?

    1 回复  |  直到 12 年前
        1
  •  5
  •   Manos Dilaverakis    17 年前

    我可以向您展示一种方法,但为了了解发生了什么,您至少需要对Magento的布局文件的工作方式有一个基本的了解。为此,您应该阅读《设计师指南》 here here .

    Magento中的块由两个文件组成,一个块类负责生成动态内容的所有工作,另一个模板文件使用块类的方法和一些html创建最终结果。获取货币选项的繁重工作已经由block类完成,因此如果我们可以将其与新模板文件结合使用,我们将进行设置。

    <block type="directory/currency" name="currency" before="catalog.leftnav" template="directory/currency.phtml"/>
    

    所以模板文件是app\design\frontend[interface][theme]\template\directory\currency.phtml

    现在创建一个名为“currency2”的新块,它由我们编写的旧块类和新模板文件组成

    <block type="directory/currency" name="currency2" as="currency2" template="directory/currency2.phtml"/>
    

    <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
    

    在相应的部分中(我假设catalog\u category\u默认)。

    最后打开/template/catalog/product/list.phtml并添加

    <?php echo $this->getChildHtml('currency2'); ?>