magento 增多一个layout template
magento 增加一个layout template
magento默认的有5中layout template方式,分别为:
empty
1columns
2columns-left
2columns-right
3columns
这么5中,有时候我们想自己做一个新的layout template让我们的页面更加的灵活,方便下面是实现的步骤:增加一个4columns 的layout template
1. 复制 app/code/core/Mage/Page/etc/config.xml
到 app/code/local/Mage/Page/etc/config.xml
. 然后打开这个文件,找到代码.
<page> <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> <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> </page>
将其替换为:
<page> <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> <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> <four_columns module="page" translate="label"> <label>4 columns</label> <template>page/4columns.phtml</template> <layout_handle>page_four_columns</layout_handle> </four_columns> </layouts> </page>
2. 在目录 app/etc/modules 中,新建文件 Mage_Local.xml 内容为:
<?xml version="1.0"?> <config> <modules> <Mage_Page> <active>true</active> <codePool>local</codePool> <depends> <Mage_Core/> </depends> </Mage_Page> </modules> </config>
3. 打开目录: app/design/frontend/your_package/your_theme/template/page
在这个文件里面新建一个文件4columns.phtml,然后随便复制一个文件,譬如:3columns.phtml,将其内容复制到4columns.phtml文件中(里面的内容,按照自己的定制改)
4. 刷新缓存,就可以使用了
来源:http://www.magentouse.com/blog/cat/magento-secondary-development/post/magento-add-layout-template/