Php 无法在Magento中创建自定义模块
我是Magento的新手,我已经开始学习为前端开发定制模块。我遵循了好几条指南,由于某种原因,它们都不起作用。似乎loadLayout和renderLayout正在引发问题。我不确定这是否是因为我有一个文件在错误的位置,或是什么问题。我已尝试加载页面magento.x/helloworld magento.x/helloworld/index magento.x/index.php/helloworld。我得到了一个默认站点的坏版本。如果我用回音来替换lLayout和rLayout,它就可以正常工作。这就是我所拥有的: app/code/local/Wrapids/Helloworld/etc/config.xmlPhp 无法在Magento中创建自定义模块,php,xml,magento,Php,Xml,Magento,我是Magento的新手,我已经开始学习为前端开发定制模块。我遵循了好几条指南,由于某种原因,它们都不起作用。似乎loadLayout和renderLayout正在引发问题。我不确定这是否是因为我有一个文件在错误的位置,或是什么问题。我已尝试加载页面magento.x/helloworld magento.x/helloworld/index magento.x/index.php/helloworld。我得到了一个默认站点的坏版本。如果我用回音来替换lLayout和rLayout,它就可以正常
<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>
app/design/frontend/default/default/layout/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>
<layout version="0.1.0">
<default>
<reference name="root">
<action method="setTemplate"><template>helloworld/page.phtml</template></action>
</reference>
</default>
</layout>
app/code/local/Wrapids/Helloworld/Block/Helloworld.php
<?php
class Wrapids_Helloworld_Block_Helloworld extends Mage_Core_Block_Template
{
}
?>
您是否已使用以下代码将Wrapids_Helloworld.xml文件添加到app/etc/modules?要加载模块,必须有此项
<?xml version="1.0"?>
<config>
<modules>
<Wrapids_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Wrapids_Helloworld>
</modules>
</config>
真的
地方的
您是否已使用以下代码将Wrapids_Helloworld.xml文件添加到app/etc/modules?要加载模块,必须有此项
<?xml version="1.0"?>
<config>
<modules>
<Wrapids_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Wrapids_Helloworld>
</modules>
</config>
真的
地方的
将模板和布局文件移动到[您的\u包]/default或[您的\u包]/[您的\u主题]将模板和布局文件移动到[您的\u包]/default或[您的\u包]/[您的\u主题]我不太理解您的目标,但您可以试试看:app/design/frontend/default/default/layout/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>
<layout version="0.1.0">
<default>
<reference name="root">
<action method="setTemplate"><template>helloworld/page.phtml</template></action>
</reference>
</default>
</layout>
helloworld/page.phtml
我不太明白你的目标,但你可以试试:app/design/frontend/default/default/layout/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>
<layout version="0.1.0">
<default>
<reference name="root">
<action method="setTemplate"><template>helloworld/page.phtml</template></action>
</reference>
</default>
</layout>
helloworld/page.phtml
如果布局xml(app/design/frontend/default/default/layout/helloworld.xml)的结束标记已损坏,请检查这是否是问题所在。哦,不是。当我在这里输入时输入错误。你的布局文件的问题。首先,删除根节点,据我所知,它是主节点。我在layout.@v.kondratyuk上看不到:我试过wrapids_helloworld_索引和默认索引。它们都没有带来变化。至于删除根节点,它应该给我留下一个完全空白的页面。看起来layout.xml甚至没有被处理。在helloworld.xml上出错,检查是否有错误,同时检查缓存。如果布局xml(app/design/frontend/default/default/layout/helloworld.xml)的关闭标记已损坏,请检查是否存在问题。哦,没有。当我在这里输入时输入错误。你的布局文件的问题。首先,删除根节点,据我所知,它是主节点。我在layout.@v.kondratyuk上看不到:我试过wrapids_helloworld_索引和默认索引。它们都没有带来变化。至于删除根节点,它应该给我留下一个完全空白的页面。看起来layout.xml甚至没有被处理。请在helloworld.xml上出错,检查是否有错误,同时检查缓存。是的,我在帖子中提到它正在使用echo,我觉得不需要添加代码。我已将这些文件复制到本地magento安装(企业版)中删除根块会导致问题。删除页脚显示没有页脚的页面。似乎一切都在运转。为了定义操作,我使用了
和内部
。在/helloworld/index/index
中,我看到了一个没有页脚的页面。是的,我在帖子中提到它与echo一起工作,我觉得我不需要添加代码。我将这些文件复制到我的一个本地magento安装(企业版)中,删除根块导致了问题。删除页脚显示没有页脚的页面。似乎一切都在运转。为了定义操作,我使用了
和内部
。在/helloworld/index/index
中,我看到了一个没有页脚的页面。希望您替换此模板的块,就像到目前为止任何类型的更改都不重要一样,使用type=”“的任何操作都不起作用。只有上面提到的Magento团队的方法以及更改块类型的方法setType,但我的尝试没有成功。我还有一个问题,我认为这是问题的根源。上面的xml布局适用于我在使用的系统上安装的一些自定义模块。一旦我有时间更深入地查看它们,我将更新此问题。希望您像到目前为止一样替换此模板的块任何类型更改都不重要,使用type=”“的操作迄今为止都不起作用。只有上面提到的Magento团队的方法以及更改块类型的方法setType,但我的尝试没有成功。我还有一个问题,我认为这是问题的根源。上面的xml布局适用于我在使用的系统上安装的一些自定义模块。一旦我有时间更深入地研究它们,我会用这个问题来更新它。