Dear all
I'm writing a plugin that adds another image to the GUI. To include the image, I put it in $plugindir/skins/default/image.png and created the required html-code with html::img(). This works so far, but I have problems getting the right path. A function local_skin_path exists and this seems to be what I'm looking for (the archive-plugin uses this). But when I call this function inside the init()-function, I get the following error:
QuotePHP Fatal error: Cannot access private property rcube_json_output::$config in /var/www/html/roundcube/program/include/rcube_plugin.php on line 243
But if I use it in a hook-handler, it returns the path to the global skin-directory instead of the path to my plugin-skin-directory.
What's wrong with my code? Or did I get something completely wrong about the local_skin_path function?
class myplugin extends rcube_plugin
{
public $task = 'mail';
private $rc;
private $skin_path;
function init()
{
$this->rc = rcmail::get_instance();
$this->skin_path = $this->local_skin_path(); //leads to error
$this->add_hook('message_headers_output', array($this, 'myaction'));
}
function myaction($p)
{
$this->skin_path = $this->local_skin_path(); //returns global skin path
return $p;
}
}
To call a template by a plugin just use:
$rcmail = rcmail::get_instance();
$rcmail->output->send('pluginfolder.templatename_without_html_extension');
OK?
Yes, but that is not my problem. I try to include an image from my templates-folder. But how to I get the path to it automagically without hardcoding it in my source?
$this->url gives the path to your plugin folder:
$this->url('image.png')
Hope that helps!
Perfectly, thank you very much skaero. That fixes my problem.
But I still don't understand, why local_skin_path() works in the "archive"-plugin but not in my code. Both call it in init()...