2

我正在 Magento (simple CRUD Application) 中创建一个新模块,并且 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 文件的内容会重复两次?我该如何解决这个问题?

4

0 回答 0