A cart dropdown plug-in I’m using has the following XML and I’m having trouble moving it to top links.
<?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>
I’ve tried changing the reference name to reference name="topLinks" and reference name="top.Links"
I’ve also tried copying the block and pasting it in local.xml under <reference name="top.links"> and putting it in page.xml but to no avail.
It should be
<reference name="top.links">as the attribute said -> reference NAMEThe problem why it is not displayed is:
– Look at the definition of
top.links-><block type="page/template_links" name="top.links" as="topLinks"/>– Then go to
Mage/Page/Block/Template/Links.phpNow we know that
top.linksextend fromcore/template.For those blocks which extend from
core/templaterequire a template (simple isn’t it),it will display everything inside the template (in your case, the template is
page/template/links.phtml)For a template, to be able to render its child, it should explicitly call
getChildHtml<?php echo $this->getChildHtml(); ?>-> will render all child under it<?php echo $this->getChildHtml('cartheader_sidebar'); ?>-> will render child with alias/namecartheader_sidebarIt means if you want
cartheader_sidebarto be displayed intop.links, you need to put<?php echo $this->getChildHtml('cartheader_sidebar'); ?>inpage/template/links.phtmlPS: I don’t check your layout, I assume it is already correct