【问题标题】:Add custom category templates to magento将自定义类别模板添加到 magento
【发布时间】:2013-07-20 21:17:31
【问题描述】:

我正在建立一个网上商店,其中包含超过 25 家不同商店的产品。对于每家商店,我们的主页都有相似但略有不同的布局。我想为每个商店子主页添加额外的模板。我发现我可以将模板添加到 local.xml 。但是我只能让它适用于一个模板。将多个模板添加到 local.xml 的正确方法是什么?

    <page>
        <layouts>
            <homepage>
                <label>Home Page</label>
                <template>page/1column-home.phtml</template>
            </homepage>
        </layouts>
    </page>

非常感谢,

【问题讨论】:

    标签: magento templates


    【解决方案1】:

    您有 2 个解决方案:-

    • 要在选择菜单中添加布局页面,因为您必须在模块 (config.xml) 中而不是在主题布局 (local.xml) 中添加 XML

    所以要实现这个创建自定义模块并在 config.xml

      <global>
        .......  
          <page>
            <layouts>
                <custom_layout_page >
                    <label>custom_layout_page</label>
                    <template>page/custom_layout_page.phtml</template>
                    <layout_handle>custom_layout_page</layout_handle>
                </custom_layout_page>
            </layouts>
        </page>
      .......
    </global>
    

    请参阅下面的屏幕:

    或:

    • 您可以在主题中创建模板 phtml 文件,例如在文件夹中

    页面/category_custom_template.phtml

    然后您可以使用您想要将此文件分配为布局页面或模板根目录的类别的布局更新

    如下图所示:

    【讨论】:

    • 嘿,谢谢你的回答!但是,如果我只添加一个新文件,它不会显示自定义布局文件......我必须将它添加到 local.xml 如上所述。我只能让一个模板工作......
    • 嗯,这不是我想要的,但它似乎有效!很奇怪我以前试过这个。我很快就会把你的遮阳篷标记为正确的!再次感谢
    • 我已经添加了你上面提到的其他解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多