<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="checkout/cart_sidebar" name="headerCart" as="headerCart" template="checkout/cart/header.phtml"/>
</block>
block中 type mane as template 各个代表什么意思?
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="checkout/cart_sidebar" name="headerCart" as="headerCart" template="checkout/cart/header.phtml"/>
</block>
block中 type mane as template 各个代表什么意思?
type的作用就是指定了该页面的功能,但是它本身不执行这些功能,而是通过.phtml也就是模板文件的$this->方法调用相关block中php文件的函数,从而在页面中实现相关的功能.
至于name,as就简单了.那name就是模块的名字,功能主要有两个:一是用于magento系统的识别,二就是用于替换.你会看到<reference name="" /> 他就是替换同名的<block neme="" >block块.从而向页面中输出同名而功能不同,或样子不同的块.
as,有的把他叫别名,作用就是在模板文件.phtml中 getChildHtml('')里面的参数就是as=""里面的名字.
由于类文件,也就是纯php文件(通过type=""加载,决定功能),block标签块(就是你写出来的,加载文件),和模板文件.phtml,三者必须是一,一对应的,,他们的名字也是必须相同的.本质上他们是一个整体,只是magento把他们分开了然后通过.xml有粘到一起了.
我说的不一定都对,你在去搜搜别的大哥为说明