Php 正在为getChildHtml()创建新块-Magento

Php 正在为getChildHtml()创建新块-Magento,php,xml,magento,block,Php,Xml,Magento,Block,我正在尝试将updateinfo块添加到客户页面 我将此代码放在customer.xml布局中 <block type="core/text_list" name="updateinfo" as="updateinfo"/> <reference name="updateinfo"> <block type="core/template" name="updateinfoBlock" template="customer/update_info.phtml" /&g

我正在尝试将updateinfo块添加到客户页面

我将此代码放在
customer.xml
布局中

<block type="core/text_list" name="updateinfo" as="updateinfo"/>
<reference name="updateinfo">
<block type="core/template" name="updateinfoBlock" template="customer/update_info.phtml" />
</reference>

并将
update_info.phtml
添加到客户文件夹中

还补充说
转到客户页面 但我还是什么都没有得到。卡住。

试试:

getChildHtml('updateinfoBlock') ?> 
而不是:


getChildHtml('updateinfo')?>

如果要使用
getChildHtml()
,则需要将
名称
属性一起设置为块的
属性。Name属性通常用于在布局文件本身中引用。如果需要通过模板文件调用块,则使用
as
属性中指定的值。所以你需要像这样的块定义

<block type="core/template" name="updateinfoBlock" as="update.info.block" template="customer/update_info.phtml" />
<?php echo $this->getChildHtml('updateinfo') ?>

你需要把这个街区称为

 <?php $this->getChildHtml('update.info.block'); ?> 

但是,
core/template
块的父块的类型为
core/text\u list
。该类型块中的子对象将自动渲染。这意味着您不需要通过
getChildHtml()
方法调用这些子对象。一些示例包括
内容
块。其中的块将自动渲染


因此,将类型为
core/template
的块直接放在布局中需要的任何位置,并如上面所示调用它。您不需要像以前那样将它括在另一个块中,除非它是必需的。

尝试使用下面的代码

<block type="core/text_list" name="updateinfo" as="updateinfo">  
   <block type="core/template" name="updateinfoBlock" template="customer/update_info.phtml" /> 
</block>

要到这个街区,你可以这样走

<block type="core/template" name="updateinfoBlock" as="update.info.block" template="customer/update_info.phtml" />
<?php echo $this->getChildHtml('updateinfo') ?>


仍然没有,甚至尝试将其放入page.xml中,但也没有。另外,我每次都在刷新Magento缓存,整个代码应该是这样的:
您也可以尝试将xml放入
page.xml
local.xml
。我知道它应该是这样的,这就是我所说的。我成功地通过了它,而没有与Danijel在xml内部创建新块,创建内联块确实有效,但是最好是对local.xml进行更改,并使用块更新和句柄,这样更容易发现问题,并防止以后出现问题。除非您有一个使用“updateinfo”参考名称的自定义模块,否则布局更新的格式将无法工作。您可以发布您的
update\u info.phtml
code吗?它只是一个简单的div,在中包含一些随机文本,用于开始,然后我将其配置为显示。它不会出现在模板提示路径中,所以我假设它不会加载到页面中。您可以发布您的customer.xml文件吗