举个例子:
<block type="core/template" name="my.name" as="myName" template="path/to/template.phtml"/>
“as = myName”声明用于什么目的。 什么抽象类为布局处理定义了这些默认属性?
答案 0 :(得分:3)
这里我可以简要介绍一下magento block xml tag
name = 块的名称。它应该在页面中是唯一的。
** as = Alias **。较小的名称形式。它在父块中应该是唯一的。
template =附加此块的模板文件(View)。
你可以使用$ this来调用块内类型的方法。例如$这 - &GT;的getName()
名称与示例:
<reference name="left">
<block type="block/blocktype1" name="first_block" template="template1.phtml">
<block type="abc/abc" name="ty1" as="common" template="abc.phtml"/>
</block>
<block type="block/blocktype1" name="second_block" template="template2.phtml">
<block type="xyz/xyz" name="ty2" as="common" template="xyz.phtml"/>
</block>
</reference>
因此,您现在可以将阻止名称ty1 from first_block
和ty2 from second_block
称为$this->getChildHtml('common');
,但是看到两个被调用的阻止符合其呼叫父级的不同。
for detail class go throw this
Understanding Magento Block and Block Type
希望这对您有所帮助。
答案 1 :(得分:1)
当您使用作为时,您可以在phtml模板上调用 $ this-&gt; getChildHtml(“as_value”)。
名称必须是唯一的,并且可以用于&lt;参考&gt;块,&lt;删除&gt;等
例如(catalog.xml):
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>