私は、ページのタイトルを変更するモジュールを作ろうとしていますが、2つのモジュールで同じクラスを拡張しますか? Magentoモジュールの競合?
Yoast_CanonicalUrlと呼ばれる別のモジュールを有効にするまで、私のモジュールは正常に動作します。
Yoastモジュールは、タイトルの方法のいずれかに触れていないが、私のモジュールと同じクラスを拡張しない:Mage_Page_Block_Html_Head {}
私はそれが存在する場合yoastクラスを拡張しようとしているが、私のモジュールが一度に機能しなくなりますyoastモジュールが有効になっています。
私は彼の方法が私に告白していないかどうかを確認するコードを見ましたが、それらはありません。
ただ、ここに私のHead.phpあるとすぐYoastはただイマイチもうロードされた私のコードをロードされているよう:(
ようだ:ここで
<?php
if (!(string)Mage::getConfig()->getModuleConfig('Yoast_CanonicalUrl')->active == 'true')
{
class Yoast_CanonicalUrl_Block_Head extends Mage_Page_Block_Html_Head{}
}
class Company_MetaKeyManager_Block_Head extends Yoast_CanonicalUrl_Block_Head
{
public function setTitle($title)
{
$this->_data['title'] = Mage::getStoreConfig('design/head/title_prefix') . ' ' . $title
. ' ' . Mage::getStoreConfig('design/head/title_suffix');
return $this;
}
public function getTitle()
{
if (empty($this->_data['title'])) {
$this->_data['title'] = $this->getDefaultTitle();
}
return htmlspecialchars(html_entity_decode(trim($this->_data['title']), ENT_QUOTES, 'UTF-8'));
}
public function getDefaultTitle()
{
return 'Hello World';
}
}
は私のConfig.xmlです:
<?xml version="1.0"?>
<config>
<modules>
<Company_MetaKeyManager>
<version>0.1.0</version>
</Company_MetaKeyManager>
</modules>
<global>
<blocks>
<MetaKeyManager>
<class>Company_MetaKeyManager_Block</class>
</MetaKeyManager>
<page>
<rewrite>
<html_head>Company_MetaKeyManager_Block_Head</html_head>
</rewrite>
</page>
</blocks>
<helpers>
<MetaKeyManager>
<class>Company_MetaKeyManager_Helper</class>
</MetaKeyManager>
</helpers>
</global>
</config>
これは古い競合です。どのMagentoのバージョンを使用していますか? Magentoには1.4以降の標準URL oobがあります。 – benmarks
私のMagentoはバージョン:1.6.2.0 CE私のバージョンは標準的なURLをすでに持っていますか? –
商品ページやカテゴリページに表示されます。管理者でオン/オフを切り替えます。 – benmarks