Sunday, March 18, 2012

magento 给cms页面增加自定义布局


Magento的布局文件一般在用的就4个,1column.phtml,2columns-left.phtml,2columns- right.phtml,3columns.phtml.今天magento互助群里有人问是不是可以弄4列的。那样就需要自己增加布局文件了。里面具体怎么布,就看你的需求了。我这里讲下如何增加magento布局文件
一、在目录app/design/frontend/default/yourtheme/template/page/ 下新建一个布局文件cmscolumn.phtml。
二、在app/design/frontend/default/yourtheme/template/layout/page.xml 中”Custom page layout handles”标签里加以下代码,其中有其他布局文件的写法,可以仿照。
1 2 3 4 5 6 7 8
<page_cms_columns translate="label"> <label>All cms-Column Layout Pages</label> <referencename="root"> <action method="setTemplate"><template>page/cmscolumn.phtml</template></action><!-- Mark root page block that template is applied --> <actionmethod="setIsHandle"><applied>1</applied></action> </reference> </page_cms_columns>
三、在app/code/core/Mage/Page/etc/config.xml中47行”layouts”标签里加入以下代码,同样有其他布局文件的写法,可参考
1 2 3 4 5
<cms_columns module="page" translate="label"> <label>cms column</label><template>page/cms.phtml</template> <layout_handle>page_cms_columns</layout_handle></cms_columns>
四.清除缓存OK

1 comment: