10
我在phtml文件里面,我怎样才能得到当前模板中的子块的列表?如何获得阻止Magento儿童?
我在phtml文件里面,我怎样才能得到当前模板中的子块的列表?如何获得阻止Magento儿童?
$children = $this->getChild();
检查应用程序/代码/法师/核心/座/ Abstract.php
public function getChild($name = '')
{
if ($name === '') {
return $this->_children;
} elseif (isset($this->_children[$name])) {
return $this->_children[$name];
}
return false;
}
中的代码因此,如果未指定名称,它只是返回所有的孩子。
我们是否也可以使用$ this-> getChildHtml()?块名称在里面? – RIK
@RIK:'$ this-> getChildHtml()'将返回所有子块的所有html内容。 –
@skafandri:在我的布局xml文件中,我添加了一个“cms/block”子元素。然后im我的父母* phtml *文件我写了'$ _block = $ this-> getChild('block_id');'然后'$ _block-> getTitle()'然后它不显示标题...既不'$ _block-> getContent()'返回html内容。如果我尝试'print_r($ _ block)'页面脚本死亡。我如何在phtml中获得我的cms块的标题? –