0

私が使用しているカートドロップダウンプラグインには次のXMLがあり、トップリンクに移動するのに問題があります。

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addCss"  ifconfig="cartdrop/general/enabled"><stylesheet>css/cartdrop.css</stylesheet></action>
            <action method="addJs"  ifconfig="cartdrop/general/enabled"><script>lib/jquery-1.4.2.min.js</script></action>
            <action method="addJs"  ifconfig="cartdrop/general/enabled"><script>lib/cartdrop.js</script></action>
        </reference>

     <reference name="top.container">
            <!--<action method="setTemplate" ifconfig="cartdrop/general/enabled"><template>cartdrop/template/header.phtml</template></action>-->

<block type="core/template" name="cartheader_sidebar" template="cartdrop/cartheader.phtml">         
    <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
        <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
        <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions"/>
    </block>
</block>

        </reference>
    </default> 
</layout>

参照名をreference name="topLinks"とに変更してみましたreference name="top.Links"

また、ブロックをコピーしてlocal.xmlに貼り付け、page.xmlに配置しようとしまし<reference name="top.links"> たが、役に立ちませんでした。



4

2 に答える 2

0

属性が言った通りである必要が<reference name="top.links">あります->参照NAME

表示されない理由は次のとおりです。-の定義を確認しますtop.links-> <block type="page/template_links" name="top.links" as="topLinks"/> -次にMage/Page/Block/Template/Links.php

class Mage_Page_Block_Template_Links extends Mage_Core_Block_Template
{
    ...

    protected function _construct()
    {
        $this->setTemplate('page/template/links.phtml');
    }

    ...
}

top.linksこれで、からの拡張がわかりましたcore/template。テンプレートを必要とするから拡張するブロックcore/templateの場合(単純ではありません)、テンプレート内のすべてが表示されます(この場合、テンプレートはpage/template/links.phtml

テンプレートの場合、その子をレンダリングできるようにするには、明示的に呼び出す必要がありますgetChildHtml

<?php echo $this->getChildHtml(); ?>->その下のすべての子をレンダリングします

<?php echo $this->getChildHtml('cartheader_sidebar'); ?>->エイリアス/名前で子をレンダリングしますcartheader_sidebar

cartheader_sidebarつまり、に表示したい場合は、top.linksを入れる必要があります<?php echo $this->getChildHtml('cartheader_sidebar'); ?>page/template/links.phtml

PS:私はあなたのレイアウトをチェックしません、私はそれがすでに正しいと思います

于 2012-08-20T03:07:56.383 に答える
0

レイアウトXML:

 <block class="Magento\Framework\View\Element\Html\Link" name="cart-link" template="Magento_Theme::cart_link.phtml">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Cart</argument>
                <argument name="path" xsi:type="string" translate="true">#/</argument>
            </arguments>
        </block>

と:

    <move element="minicart" destination="cart-link" />

cart_link.phtml:

 <li>My Cart
 <?php echo $block->getChildHtml('minicart');?>
 </li>
于 2020-04-01T14:05:23.160 に答える