首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在magento的页脚显示toplink?

如何在magento的页脚显示toplink?
EN

Stack Overflow用户
提问于 2012-05-19 18:23:29
回答 1查看 5.1K关注 0票数 2

如何在页脚中显示以下toplink,

我在Footer.phtml文件中使用了下面的代码,

代码语言:javascript
复制
<?php echo $this->getChildHtml('topLinks'); ?> 

但是链接没有显示?我该怎么做呢?

提前感谢

footer.phtml

代码语言:javascript
复制
<div class="footer-container">
    <div class="footer">
        <?php echo $this->getChildHtml() ?>
        <?php echo $this->getChildHtml('newsletter') ?>

        <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('sample_links')->toHtml() ?>

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

    <?php echo $this->getChildHtml('top.links'); ?> 


        <p class="bugs"><?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getVersion()) ?></p>
        <address><?php echo $this->getCopyright() ?></address>
    </div>
</div>
</div>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-19 18:59:44

经典学习主题-Magento问题!

一个块与另一个块的关系在模板中最为明显(正如您当前的工作所展示的那样)。父级(在本例中为页脚)触发呈现另一个块的功能需要建立父子关系。这通常发生在布局更新XML中。

如果这种关系是核心的,那么您很可能会在基本/默认主题的布局/page.xml文件中看到以下内容:

代码语言:javascript
复制
<block type="page/html_footer" name="footer" ...>
    <!-- other child block directives -->
    <block type="page/template_links" name="top.links" as="topLinks"/>
</block>

在本例中,因为要在两个现有块之间添加关系,所以可以在名为local.xml的特殊最终用户布局xml文件中设置块实例之间的关系,您应该将该文件放在自定义主题的布局文件夹中。下面是它应该是什么样子:

代码语言:javascript
复制
<?xml version="1.0"?>
<layout>
    <default><!-- effectively: "do this on all pages" --> 
        <reference name="footer"><!-- parent block -->
            <action method="insert"><!-- this PHP class method sets the relationship -->
                <block_name_to_insert>top.links</block_name_to_insert><!--use the block name in the layout, not the alias. See Mage_Core_Block_Abstract::insert() -->
                <sort_relative_to_other_childname/><!-- empty val is fine here -->
                <sort_before_or_after/><!-- not relevant -->
                <alias>topLinks</alias><!-- because you are using the original alias, need to re-specify that here -->
            </action>
        </reference>
    </default>
</layout>
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10664318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档