Roundcube Community Forum

 

Using the default plugin template

Started by Omir, June 02, 2014, 11:52:17 AM

Previous topic - Next topic

Omir

I'm having a go at creating a basic plugin based on the info here:
http://trac.roundcube.net/wiki/Doc_Plugins#Templates

I've used:
$this->register_handler('plugin.body', array($this, 'generate_html'));

Where generate_html is just returning a simple string currently, the problem is this string has now replaced settings page of another plugin I was using (CardDav).

Looking at the code of carddav plugin it has:
$this->register_handler('plugin.body', array($this, 'carddav_server_form'));

So I guess my handler for plugin.body has overridden this.

Does each plugin need its own unique template? I thought there was only a need to make a new template if the default one didn't do the job?

JohnDoh

QuoteLooking at the code of carddav plugin it has:
$this->register_handler('plugin.body', array($this, 'carddav_server_form'));

I am not familiar with the carddav plugin but look at the code more closely and you should see that that handler is only registered as part of a specific task. The "plugin.body" is a generic hook called by Roundcube when it loads the generic plugin template so in your plugin you have to set when exactly your plugin should take over. Have a look at the password or the userinfo plugins distributed with Roundcube. First they add a button to the UI with an action plugin myplugin.myaction then when that is called the plugin.body action is registered and used to add the content.

QuoteDoes each plugin need its own unique template? I thought there was only a need to make a new template if the default one didn't do the job?

Correct, you only have to make your own templates if you want to.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

Omir

Ah that was my problem then I was registering the plugin.body handler in the init of my plugin rather than inside an action. Thanks