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塊的標題? –