了解 Magento 块和块类型 [英] Understanding Magento Block and Block Type

查看:33
本文介绍了了解 Magento 块和块类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想了解一下

 <block type="page/html" name="root" output="toHtml" template="example/view.phtml">

我从谷歌那里得到了很多参考资料并且了解了很多关于它的东西,但我仍然无法理解 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 是模块的别名.在这种情况下,pageMage_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆