how to display toplinks at footer in magento?

Deadly 提交于 2019-12-21 21:52:49

问题


How can i display below toplinks in footer,

i used below code in Footer.phtml file,

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

but the links are not displayed?. How can i do this?

Thanks in advance

footer.phtml

<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>

回答1:


Classic learning-to-theme-Magento question!

The relationship of one block to another is most evident in templates (as your current effort demonstrates). The ability for a parent (footer, in your case) to trigger rendering of another block requires that a parent-child relationship be established. This typically happens in layout update XML.

If this relationship were core, it is likely that you would see the following in the base/default theme's layout/page.xml file:

<block type="page/html_footer" name="footer" ...>
    <!-- other child block directives -->
    <block type="page/template_links" name="top.links" as="topLinks"/>
</block>

In your case, because you are adding a relationship between two existing blocks, you can set up a relationship between block instances in a special end-user layout xml file named local.xml which you should place in your custom theme's layout folder. Here is what it should look like:

<?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>


来源:https://stackoverflow.com/questions/10664318/how-to-display-toplinks-at-footer-in-magento

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!