Php 如何在文件phtml magento中添加文件phtml?

Php 如何在文件phtml magento中添加文件phtml?,php,overriding,magento-1.9,Php,Overriding,Magento 1.9,我想显示内容文件:frontend\RWD\default\template\customer/address/edit.phtm 文件内部:frontend\RWD\default\template\customer/account/dashboard.phtml。 我将此代码插入到dashboard.phtml文件中 <?php $block = Mage::app()->getLayout()->createBlock('core/template')->setTe

我想显示内容文件:frontend\RWD\default\template\customer/address/edit.phtm 文件内部:frontend\RWD\default\template\customer/account/dashboard.phtml。 我将此代码插入到dashboard.phtml文件中

<?php
$block = Mage::app()->getLayout()->createBlock('core/template')->setTemplate('customer/address/edit.phtml')->toHtml();
echo $block; ?>

该部分的正确块类型是customer/address\u edit。因此,请尝试以下方法:

<?php
$block = Mage::app()->getLayout()->createBlock('customer/address_edit')->setTemplate('customer/address/edit.phtml')->toHtml();
echo $block;
?>

该部分的正确块类型是customer/address\u edit。因此,请尝试以下方法:

<?php
$block = Mage::app()->getLayout()->createBlock('customer/address_edit')->setTemplate('customer/address/edit.phtml')->toHtml();
echo $block;
?>

在这种情况下,您应该使用渲染“局部视图”,而不是您所使用的方式

在Magento,方法有些不同。基本上,Magento使用与视图中的模板关联的块,因此每个页面都由一个块PHP类(它们都继承自Mage_Core_block_Abstract)和一个关联模板(phtml文件)组成(但也有例外)

要渲染部分,块中可以有具有给定子名称的子块。从父块中,可以使用getChildHtml($childName)渲染子块。要在子块上设置变量,可以使用magic getter和setter,因为所有块PHP类最终都是从Varien_对象扩展而来的。

在本例中,您应该使用呈现“部分视图”,而不是您所使用的方式

在Magento,方法有些不同。基本上,Magento使用与视图中的模板关联的块,因此每个页面都由一个块PHP类(它们都继承自Mage_Core_block_Abstract)和一个关联模板(phtml文件)组成(但也有例外)

要渲染部分,块中可以有具有给定子名称的子块。从父块中,可以使用getChildHtml($childName)渲染子块。要在子块上设置变量,可以使用magic getter和Setter,因为所有块PHP类最终都是从Varien_对象扩展而来的