magento中的类别特定模板

时间:2012-01-23 21:39:52

标签: php magento

我在config.xml中为布局菜单添加了一个新模板:

<layouts>
    <new module="page" translate="label">
    <label>Foo</label>
    <template>page/foo.phtml</template>
    <layout_handle>page_foo</layout_handle>
    </new>  
</layouts>

一切正常,然后从管理员我可以去分类 - &gt;自定义设计和Foo将是页面布局下拉列表中的一个选项。

我的问题在于页面目录中的foo.phtml

在该文件中,页脚例如包含在

<?php echo $this->getChildHtml('footer') ?>

如果在footer.phtml所在的位置添加另一个文件,请在/ page / html /目录中说bar.phtml。然后我希望能够以同样的方式包含它。当我这样做时:

<?php echo $this->getChildHtml('bar') ?>

它没有显示出来。我想我必须在xml中的某处声明条形文件吗?我想只有当某人为某个类别选择foo布局选项时才会包含条形文件。我错过了什么?

1 个答案:

答案 0 :(得分:0)

配置中的layout_handle节点指的是它希望在一个布局文件中找到的节点。您可以在app/design/base/default/layout/page.xml中找到其他页面布局的示例。但基本上你会想要的东西......

<layout>
    <page_foo translate="label">
        <reference name="root">
            <block type="core/template" template="some/file.phtml" name="my_block" as="bar" />
        </reference>
    </page_foo>
</layout>