我是Magento的新手,我開始學習爲前端開發自定義模塊。我遵循了幾個指南,出於某種原因,他們都沒有工作。看起來好像loadLayout和renderLayout正在導致問題。我不知道這是因爲我在錯誤的位置有一個文件,或者是什麼問題。我已經嘗試加載頁面magento.x/helloworld magento.x/helloworld/index magento.x/index.php/helloworld。我收到了默認網站的損壞版本。如果我用echo來替換lLayout和rLayout,它就可以工作。這是我有:無法在Magento中創建自定義模塊
應用程序/代碼/本地/ Wrapids /的Helloworld的/ etc/config.xml中
<config>
<modules>
<Wrapids_Helloworld>
<version>0.1.0</version>
</Wrapids_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Wrapids_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
<layout>
<updates>
<helloworld>
<file>helloworld.xml</file>
</helloworld>
</updates>
</layout>
</frontend>
</config>
應用程序/代碼/本地/ Wrapids /的Helloworld /控制器/ IndexController.php
<?php
class Wrapids_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
/app/design/frontend/default/default/template/helloworld/page.phtml
text
應用程序/設計/前端/默認/日故障/佈局/ helloworld.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<default>
<reference name="content">
<block type="helloworld/helloworld" name="hello" template="helloworld/page.phtml">
</reference>
</default>
</layout>
應用程序/代碼/本地/ Wrapids /的Helloworld /座/ Helloworld.php
<?php
class Wrapids_Helloworld_Block_Helloworld extends Mage_Core_Block_Template
{
}
?>
您的佈局XML結束標記(應用程序/設計/前端/預設/默認/佈局/ helloworld.xml )壞了,檢查是否是這個問題。 –
哎呀,不。當我在這裏輸入時,輸入錯字。 – Sturm
佈局文件存在問題。首先,你刪除根節點,據我記得它是主節點。我在佈局中看不到。 –