次のコードはphtmlに$this->helper('catalog/category')ありMage::helper('catalog/category')、同じオブジェクトを返しますか?
$this->helper()and を使用する意味は何Mage::helper()ですか?
次のコードはphtmlに$this->helper('catalog/category')ありMage::helper('catalog/category')、同じオブジェクトを返しますか?
$this->helper()and を使用する意味は何Mage::helper()ですか?
回答:
基本的に$this->helperは、現在のテンプレートのブロッククラス内に含まれている関数を呼び出しています。Mage::helper「神」クラス内の関数を呼び出しています。
は$this->helper通常Mage_Core_Block_Abstract、ヘルパーのレイアウトをチェックするクラスの関数を呼び出し、ヘルパーMage::helperが見つからない場合は通常の関数を呼び出します。
/**
* Returns helper object
*
* @param string $name
* @return Mage_Core_Block_Abstract
*/
public function helper($name)
{
if ($this->getLayout()) {
return $this->getLayout()->helper($name);
}
return Mage::helper($name);
}