1
私はmagentoにとってとても新しいです。 _tohtml(アンダースコア付き)とtohtmlの違いは何ですか? _tohtmlの使用に関する関連記事は見つかりません。誰かが_tohtmlの使い方の詳細を説明できるかどうかは分かります。Magento _tohtml(アンダースコア付き)とtohtmlの違いは
私はmagentoにとってとても新しいです。 _tohtml(アンダースコア付き)とtohtmlの違いは何ですか? _tohtmlの使用に関する関連記事は見つかりません。誰かが_tohtmlの使い方の詳細を説明できるかどうかは分かります。Magento _tohtml(アンダースコア付き)とtohtmlの違いは
メソッドの宣言でコメントを参照できます。
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;
}