Trigger plugin event

A place to share your Plugins and Extensions

Trigger plugin event

Postby fc_Orson » Tue Jun 22, 2010 8:03 pm

How can i trigger an event that occurs with the view of a plugin? The event handler should also be within the plugin class.

Can someone help me please.
fc_Orson
 
Posts: 6
Joined: Tue Jun 22, 2010 7:51 pm

Re: Trigger plugin event

Postby raymond » Wed Jun 23, 2010 2:42 am

Hi,

You can do this by binding to a public mehtod on the plugin.

Here's an example:
Code: Select all
<?php
class WordBot extends RaxanPlugin {
    public static $name = 'WordBbbot';
    public static $description = "WordBot plugin";
    public static $author = "Raymond";
    protected function methods() { return get_class_methods($this); }
    public static function register() { return self::instance(__CLASS__); }

    protected function page_load($e,$page) {
        // bind click event to a public method on the plugin
        $page['a.word']->bind('click', array($this,'handler'));
    }

    // event handler
    public function handler($e) {
        $page = $e->page(); // get a reference to the page
        $page->append('Hello there!');
    }

}
WordBot::register();
?>
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: Trigger plugin event

Postby fc_Orson » Wed Jun 23, 2010 11:08 am

Thank you very much it work.
fc_Orson
 
Posts: 6
Joined: Tue Jun 22, 2010 7:51 pm


Return to Plugins & Widgets

Who is online

Users browsing this forum: No registered users and 1 guest

cron