Magento Nofrills布局以编程方式不工作Magento 1.8.1

Magento Nofrills布局以编程方式不工作Magento 1.8.1,magento,Magento,我正在努力掌握如何使用布局,偶然发现了艾伦·斯托姆的书《Nofrills Magento布局》(好书) 直到第19页,我已经阅读了这些示例,在高级块功能部分添加了一个新类 我已经按照示例创建了所有的文件和模板,但是我现在遇到了一个错误,在修复之前似乎无法继续 block类如下所示: <?php class Nofrills_Booklayout_Block_Helloworld extends Mage_Core_Block_Template { public function _cons

我正在努力掌握如何使用布局,偶然发现了艾伦·斯托姆的书《Nofrills Magento布局》(好书)

直到第19页,我已经阅读了这些示例,在高级块功能部分添加了一个新类

我已经按照示例创建了所有的文件和模板,但是我现在遇到了一个错误,在修复之前似乎无法继续

block类如下所示:

<?php
class Nofrills_Booklayout_Block_Helloworld extends Mage_Core_Block_Template
{
public function _construct()
{
        $this->setTemplate('helloworld.phtml');
        return parent::_construct();    
}
}
?>
<?php
class Nofrills_Booklayout_IndexController  extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
    $block_1 = new Mage_Core_Block_Text();
    $block_1->setText('Original Text');

    $block_2 = new Mage_Core_Block_Text();
    $block_2->setText('The second sentence');

    $main_block = new Nofrills_Booklayout_Block_Helloworld();
    //$main_block->setTemplate('../helloworld.phtml');

    $main_block->setChild('the-first',$block_1);
    $main_block->setChild('the-second', $block_2);

    //$block_1->setText('Wait, I want this text instead!');
    echo $main_block->toHtml();

}

    public function helloblockAction()
{
    $block_1 = new Mage_Core_Block_Text();
    $block_1->setText('Original Text');

    $block_2 = new Mage_Core_Block_Text();
    $block_2->setText('The second sentence');

    $main_block = new Nofrills_Booklayout_Block_Helloworld();
    //$main_block->setTemplate('helloworld.phtml');

    $main_block->setChild('the-first',$block_1);
    $main_block->setChild('the-second', $block_2);

    echo $main_block->toHtml();

}
}
<h1>hello world</h1>
<p>
<?php echo $this->getChildHtml('the-first'); ?>
</p><p>
<?php echo $this->getChildHtml('the-second'); ?>
</p>
如果任何人对我为什么会犯这个错误或我做错了什么有任何线索,我们将不胜感激

非常感谢
Graham

自动加载器正在尝试从
C:\xampp\htdocs\phmagento\includes\src\Nofrills\u Booklayout\u Block\u Helloworld.php中加载
Nofrills\u Booklayout\u Block\u Helloworld
类。您确定该文件存在吗?它应该包含第一个代码段中的块

禁用编译并重新编译所有内容。感谢马吕斯的回复,我现在知道我哪里出错了。好吧,粘贴文件并将其重命名到该位置是可行的,但我不明白为什么这本书引用将文件添加到app/code/local/Nofrills/Booklayout/Block/Helloworld.php?有什么线索吗?这是模块内部模块的正确路径。通常,如果模块设置正确,它会从那里加载,但看起来编译模式已经打开。运行compiler.php时应该填充错误中的src路径-我建议阅读以了解更多信息。好的,我明白你的意思,我已经关闭了Alan指向的complitation模式,是的,它工作起来很有魅力。非常感谢你的帮助。
http://www.phmagento.com/nofrills_booklayout/index/index
http://www.phmagento.com/nofrills_booklayout/index/helloblock

I get this error which is totally confusing me:

Warning: include(C:\xampp\htdocs\phmagento\includes\src\Nofrills_Booklayout_Block_Helloworld.php): failed to open stream: No such file or directory  in C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php on line 93
#0 C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php(93): mageCoreErrorHandler(2, 'include(C:\xamp...', 'C:\xampp\htdocs...', 93, Array)
#1 C:\xampp\htdocs\phmagento\includes\src\Varien_Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload('Nofrills_Bookla...')
#3 C:\xampp\htdocs\phmagento\app\code\local\Nofrills\Booklayout\controllers\IndexController.php(12): spl_autoload_call('Nofrills_Bookla...')
#4 C:\xampp\htdocs\phmagento\includes\src\__default.php(13969): Nofrills_Booklayout_IndexController->indexAction()
#5 C:\xampp\htdocs\phmagento\includes\src\__default.php(18331): Mage_Core_Controller_Varien_Action->dispatch('index')
#6 C:\xampp\htdocs\phmagento\includes\src\__default.php(17865): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 C:\xampp\htdocs\phmagento\includes\src\__default.php(20465): Mage_Core_Controller_Varien_Front->dispatch()
#8 C:\xampp\htdocs\phmagento\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#9 C:\xampp\htdocs\phmagento\index.php(87): Mage::run('', 'store')
#10 {main}