了解Magento块和块类型 [英] Understanding Magento Block and Block Type
问题描述
我只想了解
<block type="page/html" name="root" output="toHtml" template="example/view.phtml">
我从Google那里获得了很多参考,并且了解了很多有关它的知识,但是我仍然无法理解type="page/html"
如何为我的自定义模块形成类型.
I got many references from Google and understood many things about it but I am still unable to understand the formation of type="page/html"
how to form a type for my custom module.
请解释
type="A/B"
让我知道A和B的来源吗?
Let me know where this A and B come from?
推荐答案
A
是模块的别名.在这种情况下,page
是Mage_Page_Block
的缩写(如果要查看,请在app/code/core/Mage/Page/etc/config.xml
中定义).
The A
is a module's alias. In this case page
is short for Mage_Page_Block
(it is defined in app/code/core/Mage/Page/etc/config.xml
if you want to see).
B
是相对于别名的类名,每个单词的首字母大写.在这种情况下,html
变为Html
并附加到解析的别名中,因此它是 Mage_Page_Block_Html
.这可能在文件app/code/core/Mage/Page/Block/Html.php
中找到,因为类名直接转换为Magento中的位置.
The B
is the class name relative to the alias, initial letters of each word are capitalised. In this case html
becomes Html
and is appended to the resolved alias, so it is Mage_Page_Block_Html
. This is probably found in the file app/code/core/Mage/Page/Block/Html.php
because class names translate directly to locations in Magento.
如果您使用模型别名而不是块别名,那么page
将会是Mage_Page_Model
.资源模型和助手也会发生同样的事情.如果要使用块,模型和帮助程序,您自己的模块将需要在 config 中定义它们.
Were you using a model alias instead of a block alias then page
would be Mage_Page_Model
instead. The same thing happens for resource models and helpers too. Your own module will need to define these in it's config if it is to have blocks, models and helpers.
这篇关于了解Magento块和块类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!