我的商店中有一个类别,需要与标准洋红色布局完全不同的布局。因此,我创建了1column.phtml的新副本,并将其重命名,并进行了一个小更改以进行测试。

现在问题是自定义布局未显示。我创建了一个模块(在管理员>“ config”>“高级概述”中可以看到它。

我的文件和内容如下:

app/etc/模块/test_page.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <active>true</active>
            <codePool>community</codePool>
            <version>0.1.0</version>
            <depends>
                <Mage_Page />
            </depends>
        </Test_Page>
    </modules>
</config>

应用程序/代码/local/test/page/etc/config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <version>0.1.0</version>
        </Test_Page>
    </modules>
    <global>
        <page>
            <layouts>
                <homepage module="page" translate="label">
                    <label>Homepage</label>
                    <template>page/home.phtml</template>
                    <layout_handle>homepage</layout_handle>
                </homepage>

                <!-- add more layouts here -->
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <Test_Page>
                    <file>test_page.xml</file>
                </Test_Page>
            </updates>
        </layout>
    </frontend>
</config>

App/design/frontend/test/default/layout/test_page.xml

    <?xml version="1.0"?> 
<layout>
    <homepage translate="label">
        <label>Home Page</label>
        <reference name="root">
            <action method="setTemplate"><template>page/home.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </homepage> 
</layout>

我看不到我搞砸了的任何东西,它被看作是一个模块,但没有显示自定义布局:(

有帮助吗?

解决方案

为了使其出现在布局下拉列表中,您需要创建一个自定义模块(您还可以在核心文件中添加一些东西,但请不要这样做)。让我们命名扩展名easylife_layout。为此,您需要创建以下文件:app/etc/modules/Easylife_Layout.xml - 声明文件

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Layout>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Page />
            </depends>
        </Easylife_Layout>
    </modules>
</config>

app/code/local/Easylife/Layout/etc/config.xml - 配置文件

<?xml version="1.0"?> 
<config>
    <modules>
        <Easylife_Layout>
            <version>0.0.1</version>
        </Easylife_Layout>
    </modules>
    <global>
        <page>
            <layouts> 
                <lookbook module="page" translate="label">
                    <label>Lookbook</label>
                    <template>page/1column-lookbook.phtml</template>
                    <layout_handle>lookbook</layout_handle>
                </lookbook> 
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <easylife_layout>
                    <file>easylife_layout.xml</file>
                </easylife_layout>
            </updates>
        </layout>
    </frontend>
</config>

app/design/frontend/{interface}/{theme}/layout/easylife_layout.xml - 布局文件

<?xml version="1.0"?> 
<layout>
    <lookbook translate="label">
        <label>Lookbook</label>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </lookbook> 
</layout>

如果您想能够在布局文件中引用自定义布局,则最后一个是必要的。就像是:

<update hande="lookbook" />

清除缓存,就是这样。请让我知道这对你有没有用。

其他提示

有两种可能性:

  1. 您在类别中添加自定义布局,并执行此操作:

    <layout>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
        </reference>
    </layout>
    
  2. 您将其作为页面布局实现,并将其添加到 config.xmlglobal/page/layouts/ 但是我不知道,该怎么做。

如果您只需要一次,则可以使用第一个解决方案。但小心点。有 <action method="setIsHandle"><applied>1</applied></action> 在里面 page.xml 有时,此设置阻止了模板的更改。

做第一个解决方案:选择您的类别,必须 Custom Design 并把一切都放在 <layout /> 节点进入 Custom Layout Update Textarea,例如:

<reference name="root">
    <action method="setBackgroundGraphic">
        <background>two-pieces</background>
    </action>
    <action method="setTemplate">
    <template>page/2columns-right-highStep.phtml</template>
    </action>
    <action method="setIsHandle">
        <applied>1</applied>
    </action>
</reference>
许可以下: CC-BY-SA归因
scroll top