Magento-显示块,但仅在我使用getChildHtml调用时显示 [英] Magento - display block but only show when I call it with getChildHtml
问题描述
我创建了一个块,并将其放置到布局xml中,并且该块在我的主题中正确显示.我的问题是,直到我用getChildHtml('myblock')显式调用它之前,我实际上都不希望它显示.
I have created a block and I have placed it in to the layout xml and it is showing correctly in my theme. My problem is that I actually don't want it to display until I explicitly call it with getChildHtml('myblock').
我的块xml看起来像这样:
My block xml looks like this:
<block type="page/html" name="myblock" as="myblock" template="page/html/myblock.phtml"/ >
有人知道如何实现这一目标吗?
Anyone have a clue how to achieve this?
谢谢
推荐答案
将您的块放置在既不是core/list
类型也不调用$this->getChildHtml('')
的另一个块中(请注意为空字符串).这样,它不会自动显示,您可以随意调用它.
Place your block inside another that is neither a core/list
type nor calls $this->getChildHtml('')
(note the empty string). That way it will not be shown automatically and you are free to call it at your discretion.
这篇关于Magento-显示块,但仅在我使用getChildHtml调用时显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!