【问题标题】:My module in magento is active but not showing up我在 magento 中的模块处于活动状态但未显示
【发布时间】:2014-02-28 13:50:43
【问题描述】:

我有一个模块 (capps_cact),我在前端看不到 html 输出。我知道我的 etc/module/capps_cact.xml 文件正在工作,因为我可以进入 magento 的后端并禁用输出(config/developers/advanced)。我要做的就是在结束正文标记之前添加以下内容。

在我的配置文件中,我只有一个对布局更新文件的引用。在布局更新文件中,我只调用了一个 phtml 文件,该文件只在关闭正文之前添加了该块。我将为下面的所有文件粘贴我的代码,这里是下载 zip 文件的链接(我认为这可能更容易)。 My Source

首先我的 capps_cact.xml 位于 app/etc/modules/capps_cact.xml

<?xml version="1.0"?>
<config>
<modules>
    <capps_cact>
        <active>true</active>
        <codePool>local</codePool>
    </capps_cact>
</modules>
</config> 

现在我在 app/code/local/capps/cact/etc/config.xml 中的扩展

<?xml version="1.0"?>
<config>
<modules>
    <capps_cact>
        <version>1.0.0</version>
    </capps_cact>
</modules>
<frontend>
   <layout>
        <updates>
            <capps>
                <file>cact.xml</file>
            </capps>
        </updates>
    </layout>
</frontend>
</config>

现在我在 app/design/frontend/base/default/layout/cact.xml 中的布局文件

<?xml version="1.0"?>
<layout version="0.1.0">
<default>
    <reference name="before_body_end">
        <block type="capps/cact" name="capps_cact" as="capps_cact" template="capps/cact.phtml" />
    </reference>
</default>
</layout>

现在我在 app/design/frontend/base/default/template/capps/cact.phtml 中的块文件只有一行。

<!-- This is a test -->

【问题讨论】:

  • 看看@stackoverflow.com/questions/2451454/… ..我不确定不使用驼峰式文件名会造成什么影响。
  • 我将所有代码更改为基于 GoogleAnalytics 模块(核心)的驼峰式大小写。它似乎都是相同的案例结构,但没有解决它 =(。如果你愿意,我更新了上面的源 .zip 文件,请帮我仔细检查一下?

标签: xml magento php


【解决方案1】:

您的模块配置不正确...

  1. Cact.xml 应该是cact.xml

  2. 您没有块类型 type="capps/cact"(应该在 app/code/local/Capps/Cact/Block/Cact.php 中)或者您可以更改块类型 Understanding Magento Block and Block Type

看看@

http://excellencemagentoblog.com/magento-part4-series-helloworld

http://www.gravitywell.co.uk/blog/post/how-to-creating-your-own-custom-block-in-magento

【讨论】:

  • 工作就像一个魅力,现在我有其他问题 =)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
  • 1970-01-01
  • 2022-10-13
  • 1970-01-01
  • 2019-02-15
  • 1970-01-01
  • 2013-07-07
相关资源
最近更新 更多