【发布时间】:2012-06-07 11:13:27
【问题描述】:
我在 phtml 文件中,如何获取当前模板中的子块列表?
【问题讨论】:
标签: magento
我在 phtml 文件中,如何获取当前模板中的子块列表?
【问题讨论】:
标签: magento
$children = $this->getChild();
检查app/code/Mage/Core/Block/Abstract.php中的代码
public function getChild($name = '')
{
if ($name === '') {
return $this->_children;
} elseif (isset($this->_children[$name])) {
return $this->_children[$name];
}
return false;
}
所以如果没有给出名字,它只会返回所有的孩子。
【讨论】:
$this->getChildHtml() 将返回所有子块的所有 html 内容。
cms/block。然后我是我的父 phtml 文件,我写了$_block = $this->getChild('block_id'); 然后$_block->getTitle() 然后它不显示标题......$_block->getContent() 也不返回 html 内容。如果我尝试print_r($_block) 页面脚本就会死掉。如何在 phtml 中获取我的 cms 块的标题?