php – 为什么我对Magento Block的getTemplateFile方法的调用返
发布时间:2020-12-13 16:17:06 所属栏目:PHP教程 来源:网络整理
导读:当我在索引控制器中使用以下代码时 ?phpclass Nofrills_Booklayout_IndexController extends Mage_Core_Controller_Front_Action{ public function indexAction() { $block = new Mage_Core_Block_Template(); $block-setTemplate('helloworld.phtml'); var_
当我在索引控制器中使用以下代码时
<?php class Nofrills_Booklayout_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $block = new Mage_Core_Block_Template(); $block->setTemplate('helloworld.phtml'); var_dump($block->getTemplateFile()); } } 我希望得到这样的结果 string 'frontend/base/default/template/helloworld.phtml' (length=47) 但是,在我的系统上,我得到了 null 我的系统有什么问题,它为调用返回null <code>getTemplateFile</code> 或者我如何自己调试? 发生在Magento 1.7.0.1上. 解决方法
正如他在
original comment on the OP中指出的那样,这个问题需要一个tarball来解决问题.
必须加载Mage_Core_Block_Abstract的类定义,否则会输出有关include()或非对象操作的错误,或者根据开发人员模式可能根本没有输出. 应该注意 public function indexAction() { ini_set('display_errors',1); Mage::setIsDeveloperMode(true); $block = new Mage_Core_Block_Template(); $block->setTemplate('helloworld.phtml'); $debug = new ReflectionClass($block); echo Mage::getVersion(); Zend_Debug::dump($debug->getFileName()); Zend_Debug::dump($debug->getMethods()); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |