由于过于简单遂未翻译。
To dispatch an event, use the Mage::dispatchEvent function (/app/Mage.php). Calls look like this:

  1. $data = array( 'somedata' => 'foo', 'layout' => $this->getLayout());
  2. Mage::dispatchEvent('my_event_name', $data);

In order to observe an event, specify the observer in the config.xml file of your extension.

singleton
myextension/observer
someMethodName

Create a corresponding class and method (Observer.php) and you’re set to go:

  1. class Myextension_Model_Observer {
  2.     public function someMethodName($event) {
  3.         $layout = $event->getLayout();
  4.         $someData = $event->getSomedata();
  5.     }
  6. }

发表评论

电子邮件地址不会被公开。 必填项已用*标注