Magento的block重写规则
来源:互联网 发布:数控铣床编程格式 编辑:程序博客网 时间:2024/06/09 23:01
Magento的block重写规则是帮助和模型覆盖相似。 Magento的遵循MVC模式,但在Magento块是额外的一层。块类特定模板块呈现数据。 Magento的介绍伟大的模板设计系统block制度。
块是一个途径,使Magento的区分系统中的功能阵列,并创建一个模块化的方式来管理,从视觉和功能的观点来看它。magento有两种类型的块,他们共同创造的视觉输出。
* Structural Blocks
* Content Blocks
Magento是通过模板的模板页面的内容块的收集和整理,以全(X)HTML的输出.
如何覆盖块?
在这里,我用客户为例模块。这里我描述了各种客户为例块类覆盖系统。
a)客户登记表块(Mage_Customer_Block_Form_Register)
b)客户视图的形式块(Mage_Customer_Block_Form_View)
c)客户的地址编辑块(Mage_Customer_Block_Address_Edit)
d)客户帐户控制面板信息块(Mage_Customer_Block_Account_Dashboard_Info)
e)客户帐户控制面板地址块(Mage_Customer_Block_Account_Dashboard_Address)
六)客户部件名称块(Mage_Customer_Block_Widget_Name)
1。在第一次创建新的模块来处理下面的代码重写工作,并写在app/etc/modules/Yt_Customer.xml
<?xml version="1.0"?>
<config>
<modules>
<Yt_Customer>
<active>true</active>
<codePool>local</codePool>
</Yt_Customer>
</modules>
</config>
2。配置app/code/local/Yt/Customer/etc/config.xml。在这里,我提5 / 6块为例覆盖语法。只保留这些类的例子,你需要重写。
<?xml version="1.0"?>
<config>
<modules>
<Yt_Customer>
<version>0.1.0</version>
</Yt_Customer>
</modules>
<global>
<blocks>
<customer>
<rewrite>
<form_register>Yt_Customer_Block_Form_Register</form_register>
<form_view>Yt_Customer_Block_Form_View</form_view>
<address_edit>Yt_Customer_Block_Address_Edit</address_edit>
<account_dashboard_address>Yt_Customer_Block_Account_Dashboard_Address</account_dashboard_address>
<account_dashboard_info>Yt_Customer_Block_Account_Dashboard_Info</account_dashboard_info>
<widget_addressname>Yt_Customer_Block_Widget_Name</widget_addressname>
</rewrite>
</customer>
</blocks>
</global>
</config>
3。现在,写你的新块类并定义所有覆盖方法
a) Customer register form block override
class Yt_Customer_Block_Form_View extends Mage_Customer_Block_Account_Dashboard
{
// override existing method
//write new function
public function newmethod()
{
return true;
}
}
b) Customer view form block (Mage_Customer_Block_Form_View)
class Yt_Customer_Block_Form_View extends Mage_Customer_Block_Account_Dashboard
{
// override existing method
//write new function
public function newmethod()
{
return true;
}
}
c) Customer address edit block
class Yt_Customer_Block_Address_Edit extends Mage_Customer_Block_Address_Edit
{
// override existing method
public function getAddressStatus()
{
return $this->getRequest()->getParam('address');
}
//write new function
public function newmethod()
{
return true;
}
}
.......
- Magento的block重写规则
- Magento的helper重写规则
- Magento模型的重写规则
- 重写magento的model, block 和controller
- 重写magento的model, block 和controller
- 如何重写或者扩展magento内置Block
- Magento中Block的应用
- Magento Block的缓存机制
- Magento Block的缓存机制
- Magento的URL重写问题
- Magento的URL重写问题
- 方法重写的规则
- .htaccess -------------的重写规则,
- .htaccess的重写规则
- .htaccess的重写规则
- YII的重写规则
- Java重写的规则
- Magento的控制器改写规则
- 柠檬片泡水的功效
- 北京坐拥世界500强总部21家
- 在Windows中显示Linux的图形界面
- SNMP4J教程[转]
- 使用XmlDocument创建XML文档及增加删除更新节点
- Magento的block重写规则
- How To Automate Cleanup Of Dead Connections And INACTIVE Sessions [ID 206007.1]
- 绚丽的Jquery, CSS, MooTools 和 JS的导航菜单
- asp.net导出Excel格式数据方案
- 成功创业者的重要特质
- 每天只问小孩四句话
- LinkedHashSet
- 如何获得他人的信任
- 做web开发的算不算是真正意义上的程序员?