getChildHtml in Magento(麦进斗)
来源:互联网 发布:刷qq会员永久软件 编辑:程序博客网 时间:2024/06/05 00:35
如果我们讨论的是网站的前端,<?php echo $this->getChildHtml('content') ?> 在app/design/frontend/base/default/layout/page.xml中。在Magento版本1.8中,您会发现它在第92-94行中定义。
<block type="core/text_list"name="content" as="content" translate="label">
<label>Main Content Area</label>
</block>
通过查看这个块标记的“type”属性,我们可以知道这个布局的这个部分的对象类是什么。它来自“Core”模块,并且是块类型的文本列表。这个类以Mage_Core_Block_Text_List命名。(app/code/core/Mage/Core/Block/Text/List.php)。文本列表是一个简单的块容器,目的是在其中存储额外的子块。您可以将任意数量的子块添加到文本列表中,它们将按照添加的顺序或已分配的顺序呈现。
因此,没有视图脚本(.phtml file)呈现$this-getChildHtml('content')的内容。添加到这个块中的块,可能本身有与它们相关联的视图脚本。要找到这些视图脚本是什么,您必须找到添加了这个块的布局XML。
例如,如果我有如下的布局文件添加到我的网站主题的前端:
<?xml version="1.0"?>
<layout>
<default>
<reference name="content">
<block type="core/template" name="my_view_script"template="hello/world.phtml" />
</reference>
</default>
</layout>
上面的代码将用一个名为"content"的名称来添加一个Mage_Core_Block_Template的对象类,并将其添加到块中。然后,Magento将在以下位置查找视图脚本:
app/design/frontend/PACKAGE_NAME/THEME_NAME/template/hello/world.phtml
app/design/frontend/PACKAGE_NAME/default/template/hello/world.phtml
app/design/frontend/base/default/template/hello/world.phtml
第一个被发现的,就是它将要使用的那个。如果没有发现任何视图脚本,Magento将在var/logs/system.log(默认的日志文件设置)中记录一个错误,声明没有找到视图脚本。不会产生来自该块的输出。
请注意,根据您在 System -> Configuration -> (General) Design中的设置,可能会有附加的package/theme位置,Magento将会看到。还有其他的场景,例如,如果“Custom Theme”是针对单个CMS Pages, Catalog Categories, or Catalog Products进行更改的,那么这些单独的模型的视图页面可能会有一个附加的视图脚本位置(它将匹配所选的主题),它将优先于您的站点的默认设置。
在寻找翻译文件和布局XML文件时,Magento将遵循同样的回退逻辑。
请注意,复制单独的视图脚本(避免复制整个目录,复制您实际打算修改的视图脚本)完全可以接受,从app/design/frontend/base/default/template/到您的本地主题,并根据您的网站主题定制它们。但是,为了有一个升级兼容的站点,布局文件不应该从基础复制到您的本地主题。这样做,不遵循升级兼容的实践。相反,您的主题的XML布局更新应该包含在app/design/frontend/PACKAGE_NAME/THEME_NAME/layout/local.xml中。在app/design/frontend/base/default/layout/*,没有任何布局指令,这些指令不能在local.xml中使用适当的XML指令移除/添加/改变。
- getChildHtml in Magento(麦进斗)
- magento getChildHtml() 与getChildChildHtml()
- Magento getChildHtml函数的使用方法
- 关于得到子!!childhtml 关于------- magento getChildHtml() 与getChildChildHtml()
- 关于得到子!!childhtml 关于------- magento getChildHtml() 与getChildChildHtml()
- Bestseller products in Magento
- addAttributeToFilter Conditionals In Magento
- Using Collections in Magento
- Tax module in Magento
- addAttributeToFilter condition in Magento
- The method of getChildHtml
- Search by categories in Magento
- Custom shipping method in Magento
- Retrieving product information in Magento
- Powerful block system in Magento
- Magento Get Items In Order
- [PHP] Easy popup in Magento
- Translation in Magento shell script
- Android studio External tool jni 头文件(绝对兼容,其他人写的都有些不兼容)
- 车牌识别
- rman 恢复undo表空间
- LSTM 与 GRU
- Java基础总结
- getChildHtml in Magento(麦进斗)
- Android EditText设置只能输入数字和小数点
- 康得新在宝马、奥迪“大本营”建立研发中心
- 一文读懂监督学习、无监督学习、半监督学习、强化学习这四种深度学习方式
- [CF538C]Tourist's Notes
- 【深入Spring】——Bean
- python基础模块之-string
- static属性以及方法
- 阿里云机器学习技术分享1——图像识别之TensorFlow实现方法【视频+PPT】