【问题标题】:Add Layout Identifier in Magento Admin-Panel在 Magento 管理面板中添加布局标识符
【发布时间】:2015-10-24 06:08:17
【问题描述】:

我正在尝试创建一个 Magento 主题。到目前为止,我复制了 RWD 并根据我的意愿对其进行了修改。但是现在我遇到了一个问题。我正在尝试更改管理面板“编辑页面 - > 设计”选项卡中的可用布局。它只列出“空、1 列、2 列左栏等”。我想在这个确切的列表中添加另一个布局,但我一直无法找到要修改的相应 xml 文件。 page.xml 允许我添加布局,但它们不会显示在下拉列表中。我对“1 列”文本的所有文件进行了 grep,但没有出现。我必须在哪里查找此列表的配置?

【问题讨论】:

    标签: xml magento layout


    【解决方案1】:

    您需要一个自定义模块:

    注册你的模块:

    app/etc/modules/Dropdown_Layout.xml
    

    插入

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

    您看到我们的模块依赖于 Mage_page 核心模块。

    创建配置文件:

    app/code/local/Dropdown/Layout/etc/config.xml
    

    插入

    <?xml version="1.0"?> 
    <config>
        <modules>
            <Dropdown_Layout>
                <version>1.0.0</version>
            </Dropdown_Layout>
        </modules>
        <global>
            <page>
                <layouts> 
                    <newlayout module="page" translate="label">
                        <label>newlayout</label>
                        <template>page/newlayout.phtml</template>
                        <layout_handle>newlayout</layout_handle>
                    </newlayout> 
                </layouts>
            </page>
        </global>
        <frontend>
            <layout>
                <updates>
                    <Dropdown_Layout>
                        <file>Dropdown_Layout.xml</file>
                    </Dropdown_Layout>
                </updates>
            </layout>
        </frontend>
    </config>
    

    你在配置文件中引用的布局文件

    app/design/frontend/rwd/your_theme/layout/dropdownlayout.xml
    

    插入

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

    还有实际的html文件:

    app/design/frontend/rwd/your_theme/template/page/newlayout.phtml
    

    并插入您的 html 模板

    <!DOCTYPE html>
    <html lang="en" id="top" class="no-js">
        <head>
            ...
    

    分配模板:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-30
      • 2014-08-23
      相关资源
      最近更新 更多