【问题标题】:How can I duplicate Magento top.links into header and footer如何将 Magento top.links 复制到页眉和页脚中
【发布时间】:2013-10-04 16:04:14
【问题描述】:

我是 Magento 主题的新手,正在尝试做一些基本的主题更改。

我想在页眉和页脚中显示相同的 top.links 菜单。

我在 page.xml 的页脚中添加了块:

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>

并将此代码添加到footer.phtml

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

执行此操作后,菜单显示在页脚中,但不再显示在页眉中。我猜一个块只能显示一次?如何在页眉和页脚都显示它?

谢谢。

【问题讨论】:

  • 你可以在没有 xml 的情况下调用它。只需在页脚页面中调用此 getChildHtml('topLinks') ?>。
  • @K-THIHA - 我尝试了这个,但没有成功。只是想出了 DIV 中的任何内容。

标签: magento


【解决方案1】:

在您的布局 page.xml 文件中:

        <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
            <block type="page/template_links" name="footer.links" as="footerLinks">
                //you need to add the links you wanna show here, for example:
                <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
                //search for 'addLink' in the layout xml files to find all the links you want
            </block>
            ...//rest of footer's content
        </block>

在你的footer.phtml中:

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

【讨论】:

    【解决方案2】:

    我认为你不需要复制 xml 中的块,如果你只是复制页脚文件中的代码就可以了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多