2

フッターのトップリンクの下に表示するにはどうすればよいですか?

ここに画像の説明を入力

Footer.phtml ファイルで以下のコードを使用しました。

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

リンクが表示されませんか?これどうやってするの?

前もって感謝します

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

1 に答える 1

10

テーマへの古典的な学習 - Magento の質問!

あるブロックと別のブロックの関係は、テンプレートで最も明確になります (現在の取り組みが示すように)。親 (この場合はフッター) が別のブロックのレンダリングをトリガーできるようにするには、親子関係を確立する必要があります。これは通常、レイアウト更新 XML で発生します。

この関係がコアである場合、base/default テーマのlayout/page.xmlファイルに次のように表示される可能性があります。

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

あなたの場合、2 つの既存のブロック間の関係を追加しているため、カスタム テーマのレイアウトフォルダーに配置する必要があるlocal.xmlという名前の特別なエンド ユーザー レイアウト xml ファイルで、ブロック インスタンス間の関係を設定できます。これは次のようになります。

<?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>
于 2012-05-19T10:59:44.143 に答える