【问题标题】:what is use of loadlayout and renderlayout and what can they do?loadlayout 和 renderlayout 有什么用,它们能做什么?
【发布时间】:2014-12-10 06:56:38
【问题描述】:

loadlayout() 和 renderlayout() 是做什么的? 在控制器的功能中

 public function viewAction()
 {
 $this->loadLayout();
 $this->renderLayout();
 }

【问题讨论】:

    标签: php function magento controller magento-1.9


    【解决方案1】:

    $this->renderLayout(); 获取布局输出并将此输出处理为响应正文并附加响应

    $this->loadLayout(); 在后端创建 XML 树。

    【讨论】:

      【解决方案2】:

      当你调用 Action Controller 的 loadLayout 方法时,Magento 会

      1. 为每个标签实例化一个 Block 类,使用标签的 type 属性作为全局配置路径查找类,并将其存储在布局对象的内部 _blocks 数组中,使用标签的 name 属性作为数组键。

      2. 如果标签包含一个输出属性,它的值被添加到布局对象的内部_output数组中。

      然后,当您在 Action Controller 中调用 renderLayout 方法时, Magento 将遍历 _output 数组中的所有 Block,使用 output 属性的值作为回调方法。

      这始终是 toHtml,意味着输出的起点将是该块的模板。

      干杯 ;-)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-24
        • 1970-01-01
        • 1970-01-01
        • 2017-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多