【发布时间】:2012-11-21 19:19:59
【问题描述】:
我一直在为 Magento 开发一个插件,我的 layout/name.xml 文件中有一个全局块,其中没有 xml 标签:
<block name="one.two.three" template="project/button.phtml" />
这个想法是能够在任何地方调用 getBlockHtml("one.two.three") 并能够看到 beta.phtml。我得到这个工作没有问题。
为了测试插件的安装过程,我尝试从头开始安装另一个 magento。我将插件安装到与第一个插件相同的目录中,并从我的旧安装中复制/粘贴了 getBlockHtml,但没有出现任何内容(甚至没有模板提示)!添加默认引用没有帮助。
它显然没有检测到我的 xml 文件,尽管 adminhtml 菜单和 mysql 安装脚本都可以工作。知道为什么会这样吗?是的,我已经清除了无数次缓存。
编辑:
两个安装都是版本 1.7.0.2
这两个安装都在同一台计算机上,因此它们的文件系统和外壳大概是相同的。同一台计算机上的两个人在区分大小写方面是否会有所不同?
安装插件:我们有一个脚本,可以将文件复制到 Magento 安装中,到目前为止,它一直在第一次安装中工作,这也是我对第二次安装所做的。为了确认,在复制文件时会添加 magento 数据库中的条目和表。
我的布局存储在一个通用布局文件夹中:app/design/layout/projectEmbeds.xml。我意识到这不是常见的约定,但在我开始这个项目之前就是这样,而且它正在工作,所以我没有搞砸它。我认为做出这个决定是为了让它看起来独立的网站主题。
同样,我的插件存储在 app/code/local/ -> Project/Embeds 中,其中包含 Blocks、控制器等、Helper、Model 和 sql。
有问题的 button.phtml 位于 app/design/frontend/default/default/project 中
我上面目录中etc中存放的config.xml文件如下。任何引用 Project_Banner 的东西都很重要,而 Project_Embed 几乎完全被弃用了。
<config>
<modules>
<Project_Embeds>
<version>0.1.0</version>
</Project_Embeds>
</modules>
<frontend>
<routers>
<embeds>
<use>standard</use>
<args>
<module>Project_Embeds</module>
<frontName>embeds</frontName>
</args>
</embeds>
</routers>
<layout>
<updates>
<embeds>
<file>projectEmbeds.xml</file>
</embeds>
</updates>
</layout>
</frontend>
<global>
<resources>
<project_embed_setup>
<setup>
<module>Project_Embeds</module>
<class>Project_Embeds_Model_Mysql4_Setup</class>
</setup>
</project_embed_setup>
</resources>
<models>
<embeds>
<class>Project_Embeds_Model</class>
<resourceModel>embeds_mysql4</resourceModel>
</embeds>
<projectbanner>
<class>Project_Banner_Model</class>
<resourceModel>banner_mysql4</resourceModel>
</projectbanner>
<embeds_mysql4>
<class>Project_Embeds_Model_Mysql4</class>
<entities>
<embeds>
<table>project_embed</table>
</embeds>
<banner>
<table>project_banner</table>
</banner>
</entities>
</embeds_mysql4>
</models>
<resources>
<embeds_setup>
<setup>
<embeds>Project_Embeds</embeds>
</setup>
<connection>
<use>core_setup</use>
</connection>
</embeds_setup>
<embeds_write>
<connection>
<use>core_write</use>
</connection>
</embeds_write>
<embeds_read>
<connection>
<use>core_read</use>
</connection>
</embeds_read>
</resources>
<blocks>
<embeds>
<class>Project_Embeds_Block</class>
</embeds>
</blocks>
<helpers>
<embeds>
<class>Project_Embeds_Helper</class>
</embeds>
</helpers>
</global>
<admin>
<routers>
<thisprojectname>
<use>admin</use>
<args>
<module>Project_Embeds</module>
<frontName>project</frontName>
</args>
</thisprojectname>
</routers>
<!-- default admin design package and theme -->
<design>
<package>
<name>base</name>
</package>
<theme>
<default>default</default>
</theme>
</design>
</admin>
<adminhtml>
<menu>
<embeds translate="title" module="embeds">
<title>Project</title>
<sort_order>9999</sort_order>
<children>
<projectbanner module="embeds">
<title>Edit Coupon</title>
<sort_order>1</sort_order>
<action>embeds/adminhtml_banner</action>
</projectbanner>
</children>
</embeds>
</menu>
<layout>
<updates handle="index_settings">
<embeds>
<file>projectEmbeds.xml</file>
</embeds>
</updates>
</layout>
</config>
【问题讨论】:
-
那么你应该关闭这个问题。有必要开一会没有任何回应吗!
-
如果你有一个有用的答案,并且它有效,我会接受你的答案。如果你不这样做,那么请用你的时间做点别的事情。这不是我在 stackoverflow 上应该期待的行为。
-
或者,也许您没有正确提问。如果您提供更多或更好的信息,那么也许人们会提供帮助并提供答案。
-
然后询问更多信息,我尽量提供我认为重要的一切。我上面给出的帖子也适用于你。我目前没有理由相信你们中的任何一个都使用 Magento。如果你不是为了高效工作,那就继续前进。谢谢。
-
@AndreyTserkus 的关键点 - 模块路径。一个系统区分大小写的 FS 而另一个不区分?
标签: magento magento-layout-xml