【问题标题】:Magento what is the different between _tohtml(with underscore) and tohtmlMagento _tohtml(带下划线)和 tohtml 有什么区别
【发布时间】:2016-11-08 13:38:56
【问题描述】:

我对 magento 很陌生。我能知道_tohtml(带下划线)和tohtml有什么不同吗?我找不到任何有关使用 _tohtml 的相关文章。如果有人能详细解释如何使用 _tohtml,将不胜感激。

【问题讨论】:

    标签: magento-1.9


    【解决方案1】:

    您可以在方法声明中看到 cmets。

    tohtml() 是一个不能被覆盖的最终方法。

    但如果需要,您可以覆盖子块中的 _tohtml() 方法。

       final public function toHtml()
        {
            Mage::dispatchEvent('core_block_abstract_to_html_before', array('block' => $this));
            if (Mage::getStoreConfig('advanced/modules_disable_output/' . $this->getModuleName())) {
                return '';
            }
            $html = $this->_loadCache();
            if ($html === false) {
                $translate = Mage::getSingleton('core/translate');
                /** @var $translate Mage_Core_Model_Translate */
                if ($this->hasData('translate_inline')) {
                    $translate->setTranslateInline($this->getData('translate_inline'));
                }
    
                $this->_beforeToHtml();
                $html = $this->_toHtml();
                $this->_saveCache($html);
    
                if ($this->hasData('translate_inline')) {
                    $translate->setTranslateInline(true);
                }
            }
            $html = $this->_afterToHtml($html);
    
            /**
             * Check framing options
             */
            if ($this->_frameOpenTag) {
                $html = '<'.$this->_frameOpenTag.'>'.$html.'<'.$this->_frameCloseTag.'>';
            }
    
            /**
             * Use single transport object instance for all blocks
             */
            if (self::$_transportObject === null) {
                self::$_transportObject = new Varien_Object;
            }
            self::$_transportObject->setHtml($html);
            Mage::dispatchEvent('core_block_abstract_to_html_after',
                    array('block' => $this, 'transport' => self::$_transportObject));
            $html = self::$_transportObject->getHtml();
    
            return $html;
        }
    

    【讨论】:

      猜你喜欢
      • 2021-09-02
      • 2016-07-20
      • 1970-01-01
      • 2019-09-21
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 2017-06-03
      • 2023-03-23
      相关资源
      最近更新 更多