【问题标题】:Custom currency switcher in Magento header vanished?Magento 标题中的自定义货币切换器消失了?
【发布时间】:2013-02-21 15:25:28
【问题描述】:

我昨天为我的标题构建了一个自定义货币切换器,一切正常。今天我来设置目录页面,发现自己需要删除左栏中的标准货币切换器,我打开了我的 local.xml 并添加了对货币的删除。也许是愚蠢的选择,当我突然注意到我在其中一个文件中所做的某些事情阻止了我的标题自定义货币切换器显示时,我设法让 left.currency 被删除。

local.xml

<?xml version="1.0" encoding="UTF-8"?>
    <layout>
    <default>
    <!-- Remove callouts and rarely used stuff -->
    <remove name="right.poll"/>
    <remove name="right.permanent.callout"/>
    <remove name="left.permanent.callout"/>
    <remove name="paypal.partner.right.logo"/>
    <remove name="catalog.compare.list" />

    <!-- add the local stylesheet -->
    <reference name="head">
        <action method="addCss"><stylesheet>css/smoothness/jquery-ui-1.10.1.custom.css</stylesheet></action>
        <action method="addJs"><script>ahoy/jquery-1.9.1.js</script></action>
        <action method="addJs"><script>ahoy/jquery-ui-1.10.1.custom.js</script></action>
        <action method="addJs"><script>ahoy/script.js</script></action>

        <action method="addCss"><stylesheet>css/1140.css</stylesheet></action>
        <action method="addCss"><stylesheet>css/ahoy.css</stylesheet></action>          
    </reference>
    <reference name="header">
        <block type="template/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
    </reference>

</default>

<catalog_category_view>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    </reference>
</catalog_category_view>

header.phtml 的第一部分

<div class="header">
<div class="row">
    <div class="row">   
        <div class="sixcol">
            <?php echo $this->getChildHtml('topLinks') ?>
            <?php echo $this->getChildHtml('custom_currency_selector') ?>
        </div>
        <div class="sixcol last">
            <div class="row">

test/default/template/currency/currency.phtml

<?php if($this->getCurrencyCount() > 1): ?>
<div class="currency-block">
<ul>
    <?php foreach ($this->getCurrencies() as $_code => $_name): ?>

    <?php $active = ($_code==$this->getCurrentCurrencyCode()) ? "active":""; ?>
    <li>
        <a class="<?php echo $active; ?>" href="<?php echo $this->getSwitchCurrencyUrl() . "currency/" . $_code; ?>" title="Set <?php echo $_code; ?> as your chosen currency">
            <?php echo Mage::app()->getLocale()->currency($_code)->getSymbol(); ?>
        </a>
    </li>
    <?php endforeach; ?>
</ul>

据我所知,这就是创建块、分配其位置并调用它所需的全部内容。我在摆弄时一直在清除缓存,我重新加载了货币转换数据,在本地删除并重新测试了删除左条货币的“删除”,在我删除了 left.currency 的删除后,现在又回来了但第一名再也没有回来。

这些是我当前的文件,所以现在根本没有删除货币,我不确定这什么时候消失了,但我一直在玩左侧边栏的东西,在 css 挣扎之后我试图删除货币并且作为我不知道如何引用它试图杀死我能找到的所有货币,当我抽动时,我不再确定何时删除了顶级货币。

【问题讨论】:

    标签: magento block magento-1.7


    【解决方案1】:

    尝试将type="template/currency" 更改为type="directory/currency"

    【讨论】:

    • 您指定了template/currency,其中不存在该名称的块类型。在您的布局 xml 文件(app/design/frontend/base/default/layout)中,您会找到一个名为 directory.xml 的文件,它引用了货币的块类型。它用block type="directory/currency" 指向template="directory/currency.phtml"。如果那个块类型是"template/currency",那么你的代码就可以工作了。我希望这能澄清一点。
    猜你喜欢
    • 2011-03-28
    • 1970-01-01
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多