Hi
I'm trying to create a roundcube plugin. I have managed to add a button to the taskbar and I've created a template file in skins/elastic/templates/mytemplate.html . Now I want the template to be displayed when the taskbar button is pressed.
This is what i've got so far
class my_plugin extends rcube_plugin
{
//Plugin initialization
function init()
{
$this->load_config();
$this->add_texts("localization/");
$this->add_hook("startup", array($this, "create_gui"));
}
function create_gui($args)
{
$this->include_stylesheet($this->local_skin_path()."/files.css");
//Add taskbar button
$this->add_button(array(
"command" => "files",
"class" => "eg-button-files",
"classsel" => "eg-button-files eg-button-files-selected",
"innerclass" => "eg-inner inner",
"label" => "my_plugin.files",
"type" => "link"
), "taskbar");
}
}
Have a look at the help plugin which ships with Roundcube for an example. Its something like this:
class my_plugin extends rcube_plugin
{
//Plugin initialization
function init()
{
$this->load_config();
$this->add_texts("localization/");
$this->add_hook("startup", array($this, "create_gui"));
// register a new task for this plugin
$this->register_task('my_plugin');
// register a handler for the default task action
$this->register_action('index', [$this, 'mytemplate']);
}
function create_gui($args)
{
$this->include_stylesheet($this->local_skin_path()."/files.css");
//Add taskbar button
$this->add_button(array(
"command" => "switch-task",
"prop" => "my_plugin",
"class" => "eg-button-files",
"classsel" => "eg-button-files eg-button-files-selected",
"innerclass" => "eg-inner inner",
"label" => "my_plugin.files",
"type" => "link"
), "taskbar");
}
function mytemplate()
{
$rcmail = rcmail::get_instance();
// register handler for template object "my_plugin.body"
$rcmail->output->add_handler('my_plugin.body', [$this, 'body']);
// output template called mytemplate.html
$rcmail->output->send('my_plugin.mytemplate');
}
function body($attrib)
{
return "<b>content</b>";
}
}