0
我試圖做一個重寫塊的例子。我以爲我正確地按照說明操作,但沒有任何反應。某處有錯誤嗎?Magento - 覆蓋塊
要覆蓋的塊是Mage_Page_Block_Html_Head。 我做塊的重寫config.xml中:
<config>
<blocks>
<html>
<rewrite>
<head>Hello_Mymodule_Block_Head</head>
</rewrite>
</html>
</blocks>
</config>
然後,我在創建Head.php:應用程序 - 代碼 - 本地 - 你好 - Mymodule中 - 塊 - Head.php。
我從原來的Head.php的方法的getTitle複製到我的新Head.php,然後我只是把「模()」,看看它的工作原理:
class Hello_Mymodule_Block_Head extends Mage_Page_Block_Html_Head {
public function getTitle()
{
die();
if (empty($this->_data['title'])) {
$this->_data['title'] = $this->getDefaultTitle();
}
return strtoupper(htmlspecialchars(html_entity_decode(trim($this->_data['title']), ENT_QUOTES, 'UTF-8')));
}}
什麼也沒有發生,我不知道如何搜索錯誤。我的模塊是活動和工作(它顯示在管理員)
太棒了,謝謝!我不認爲「頁面」是一個塊,因爲它包含「塊」文件夾。你知道這背後的邏輯嗎?是否「頁面」是一個塊,即使它在塊文件夾之外? – Galivan
Page是模塊名稱,您正在重寫位於html文件夾下的塊頭。 – rajatsaurastri