【发布时间】:2015-06-10 07:36:54
【问题描述】:
我已经在 app/code/local/mycustom/GeoLocation 的 magento 中创建了我的自定义模块,因为我想创建一个观察者,所以我遵循了很多教程,最后我创建了下面的代码来调用它magento 的页面加载,但它仍然没有调用我的自定义模块的observer.php。我是 magento 的新手,所以请帮助我。
config.xml
<config>
<global>
<events>
<cms_page_render>
<observers>
<mycustom_GeoLocation_Model_observer>
<type>singleton</type>
<class>mycustom_GeoLocation_Model_Observer</class>
<method>getGeoLocation</method>
</mycustom_GeoLocation_Model_observer>
</observers>
</cms_page_render>
</events>
</global>
</config>
用于启用模块的 mycustomGeolocation_Event.xml
<config>
<modules>
<mycustom_GeoLocation>
<active>true</active>
<codepool>local</codepool>
</mycustom_GeoLocation>
</modules>
</config>
最后我的observer.php出现在我的自定义模块的模型中
class mycustom_GeoLocation_Model_Observer {
public function __construct()
{
}
public function getGeoLocation(Varien_Event_Observer $observer) { // current layout
$event = $observer->getEvent();
$cms_page = $event->getPage();
echo "called";
exit;
return $this;
}
}
【问题讨论】: