2014-01-29 171 views
0

我试过创建一个新模块。为此,我创建了indexController,config.xml,block,layout和其他所需文件,尽管我无法查看我在我的块文件中写入的消息。每当URL被触发(http://mydomain.com/foobar/)时,应该显示“它来自foo栏”的输出,但此时它不起作用。自定义模块问题

My indexController.php code : 

class Foo_Bar_IndexController extends Mage_Core_Controller_Front_Action 
{ 
    public function indexAction() 
    { 
     $this->loadLayout(); 
     $this->renderLayout(); 
    } 
} 

Code related to block : 

class Foo_Bar_Block_News extends Mage_Core_Block_Template 
{ 
    public function _prepareLayout() 
    { 
     return parent::_prepareLayout(); 
    } 

    public function fetchRow() 
    {    
     echo "it is from foo bar";  
    } 
} 

code related to config.xml : 

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Foo_Bar> 
      <version>1.0.0</version> 
     </Foo_Bar> 
    </modules> 
    <frontend> 
     <routers> 
      <foobar> 
       <use>standard</use> 
       <args> 
        <module>Foo_Bar</module> 
        <frontName>foobar</frontName> 
       </args> 
      </foobar> 
     </routers> 
     <layout> 
      <updates> 
       <bar> 
        <file>foobar.xml</file> 
       </bar> 
      </updates> 
     </layout> 
     <!--<events> 
      <catalog_product_load_after> 
       <observers> 
        <foo_bar> 
         <type>model</type> 
         <class>foo_bar/observer</class> 
         <method>catalogProductLoadAfter</method> 
        </foo_bar> 
       </observers> 

      </catalog_product_load_after> 
     </events>--> 
    </frontend> 
    <global> 
    <blocks> 
      <foobar> 
       <class>Foo_Bar_Block</class> 
      </foobar> 
     </blocks>    
    </global> 
</config> 


code related to layout.xml 

<?xml version="1.0" encoding="UTF-8"?> 
<layout version="0.1.0"> 
    <default> 
     <reference name="content"> 
     </reference> 
    </default> 
    <foobar_index_index> 
     <reference name="content"> 
      <block type="foobar/news" name="news_test" template="bar/check.phtml"/> 
     </reference> 
    </foobar_index_index> 
</layout> 

Code related to template file 

<?php 
echo $this->fetchRow() 
?> 

任何帮助意识到这一点将不胜感激。

回答

1

在我的情况下解决这个问题是从管理中禁用编译。其他一切都很好。从admin中禁用编译后获得所需的输出。

要禁用编辑登录到您的magento项目的管理端,然后转到系统>>工具>>编译,然后单击禁用按钮来禁用编译。