Magento问题的phtml文件被调用两次

时间:2013-08-18 16:35:55

标签: crud php magento

我正在Magento中创建一个新模块(简单的CRUD应用程序),并且多次调用phtml文件(两次)。以下是我在布局xml文件中的代码

<?xml version="1.0"?>
<layout version="0.1.0">
    <businesshours_index_index>
        <reference name="content">
            <block type="businesshours/businesshours" name="businesshours" template="businesshours/businesshours.phtml" />
        </reference>
    </businesshours_index_index>
</layout> 

这就是我的块类中的方法: -

<?php

class Techmentation_Businesshours_Block_Businesshours extends Mage_Core_Block_Template
{
    public function __construct()  
    {       
        parent::__construct(); 
        $branches = Mage::getModel('businesshours/businesshours')->getCollection();
        $this->setCollection($branches);   
    }  

    public function getPostActionUrl()
    {       
        return $this->helper('businesshours')->getBusinesshoursPostUrl(); 
    }

    public function _prepareLayout()
    {
        return parent::_prepareLayout();
    }

    public function getBusinesshours()     
    { 
        if (!$this->hasData('businesshours')) {
            $this->setData('businesshours', Mage::registry('businesshours'));
        }
        return $this->getData('businesshours');
    }

}

为什么phtml文件的内容会重复两次?我该如何解决这个问题?

0 个答案:

没有答案