magento 构建布局

magento中默认的布局文件为1column.phtml,2columns-left.phtml,2columns-right.phtml,3columns.phtml
其实我们是可以增加自己需要的布局文件的。页面的内容具体要什么样子的,这就看自己的需求了。增加magento布局文件的方法步骤如下。

一、新建一个布局文件newcolumn.phtml 这个newcolumn.phtml根据自己的需要进行设置。大体和默认的几个布局文件的结构一致,调用的内容块一致就ok了.
二、在layout\page.xml中标签里加以下代码,可以参考默认的几个布局文件。

[xml]
<page_new_columns translate="label">
       <label>All new-Column Layout Pages</label>
       <reference name="root">
            <action method="setTemplate"><template>page/newcolumn.phtml</template></action>
            <!-- Mark root page block that template is applied -->
            <action method="setIsHandle"><applied>1</applied></action>
       </reference>
</page_new_columns>
[/xml]

三、在code\core\mage\page\etc\config.xml中这个标签里 下的 里加入以下代码,同样有其他布局文件的写法,(可以参考其他的布局写法)

[xml]
<new_columns module="page" translate="label">
       <label>new column</label>
       <template>page/newcolumn.phtml</template>
       <layout_handle>page_new_columns</layout_handle>
</new_columns>
[/xml]

完成上述的几步之后,在Magento后台选择layout的时候 就会多一项new cloumn的选项。或者是要通过设置catalog.xml在需要调用到该布局文件的地方改成相应的标签就ok了。例如需要在Product view 页面调用该布局文件可以修改

[xml]
<reference name="root">
    <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
[/xml]

成相应的

[xml]
<reference name="root">
    <action method="setTemplate"><template>page/newcolumn.phtml</template></action>
</reference>
[/xml]

这样在product view页面就调用了新的布局文件了。这样就给我们前台设计带来的更大的方便。可以根据我们的需要来设定magento的前台显示结果。


转载于:https://my.oschina.net/liufeng815/blog/353518

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值