magento 1.9.1.0 无法识别本地自定义模块

Local custom module not recognized in magento 1.9.1.0

我在 code/local codepool 文件夹中为 magento 自定义列布局、magento 自定义价格和 magento 自定义文件扩展名(该扩展名应该允许任何视频文件)创建了三个不同的模块。

我遵循了 code/core 代码池中每个模块的文件夹结构。但是这些模块无法识别。

为了测试我的代码是否正确,我将 magento 自定义列布局 config.xml 代码粘贴到 app/code/core/Mage/Page/etc 以更新它并且它有效。

问题: 我的代码如何在 code/local 代码池中工作?

这是我工作的 magento 自定义列布局 config.xml 文件的一部分。

<layouts>
    <empty module="page" translate="label">
        <label>Empty</label>
        <template>page/empty.phtml</template>
        <layout_handle>page_empty</layout_handle>
    </empty>
    <one_column module="page" translate="label">
        <label>1 column</label>
        <template>page/1column.phtml</template>
        <layout_handle>page_one_column</layout_handle>
        <is_default>1</is_default>
    </one_column>
    <full_column module="page" translate="label">
        <label>Full 1 column</label>
        <template>page/full1column.phtml</template>
        <layout_handle>page_one_column_full</layout_handle>
        <is_default>1</is_default>
    </full_column>
    <two_columns_left module="page" translate="label">
        <label>2 columns with left bar</label>
        <template>page/2columns-left.phtml</template>
        <layout_handle>page_two_columns_left</layout_handle>
    </two_columns_left>
    <two_columns_right module="page" translate="label">
        <label>2 columns with right bar</label>
        <template>page/2columns-right.phtml</template>
        <layout_handle>page_two_columns_right</layout_handle>
    </two_columns_right>
    <three_columns module="page" translate="label">
        <label>3 columns</label>
        <template>page/3columns.phtml</template>
        <layout_handle>page_three_columns</layout_handle>
    </three_columns>
</layouts>

谢谢!

Config.xml 只是模块的配置文件,并不用于(直接)布局更新。为此,您必须为每个模块创建一个 config.xml 文件,并在该文件中创建 XML 指令,通过 XML 节点 "updates",对 magento "this is the path for the layout file of this module":

...
<frontend>
    ...
    <layout>
        <updates>
            <(modulename)>
                <file>(name_of_layout_file.xml)</
            </(modulename)>
        </updates>
    </layout>
</frontend>

From: Frontend (Magento - Wiki - config.xml Reference)

现在,您必须在模板的布局文件夹中创建该文件,将更新全局布局所需的所有代码放入其中。

更多信息:

抱歉,我 post 这个问题已经有一段时间了。过去几周我一直在休假,所以我没有时间访问此页面。

我已经想出了解决这类问题的方法。

开发人员创建的每个自定义模块都应首先将其注册到 app/etc/modules 文件夹。

第 1 步:我按照 app/code/core 的文件夹结构将其放在 app/code/local 上。结构是这样的 app/code/local/Mage/Page/etc/config.xml

第 2 步:注册我的新模块。我在 app/etc/modules 中创建了一个 .xml 文件并将其命名为我想要的任何名称。

第 3 步:我打开我创建的 .xml 文件并添加这段代码

<?xml version="1.0"?>
<config>
        <modules>
            <Mage_Page><!-- <Mage_Page> tag came from two folders. Mage is my namespace from app/code/local/Mage and Page is my module name from app/code/local/Mage/Page. -->
                <active>true</active>
                <codePool>local</codePool>
            </Mage_Page>
        </modules>
</config>

第 4 步:保存您拥有的所有文件 created/updated。

第 5 步:我刷新管理页面并检查我的工作是否正常,是的。

由于缺乏开发 magento 的知识和经验,这花了我一段时间。不过谢谢你的帮助。

谢谢!