Author Topic: local_skin_path troubles  (Read 6604 times)

Offline neonknight

  • Newbie
  • *
  • Posts: 6
local_skin_path troubles
« on: December 14, 2009, 04:42:27 AM »
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:
Quote
PHP 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?
Code: [Select]

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;
}
}


Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
local_skin_path troubles
« Reply #1 on: December 14, 2009, 02:05:30 PM »
To call a template by a plugin just use:

$rcmail = rcmail::get_instance();
$rcmail->output->send('pluginfolder.templatename_without_html_extension');

OK?
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline neonknight

  • Newbie
  • *
  • Posts: 6
local_skin_path troubles
« Reply #2 on: December 14, 2009, 02:42:46 PM »
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?

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
local_skin_path troubles
« Reply #3 on: December 14, 2009, 02:53:40 PM »
$this->url gives the path to your plugin folder:

$this
->url('image.png')

Hope that helps!

Offline neonknight

  • Newbie
  • *
  • Posts: 6
local_skin_path troubles
« Reply #4 on: December 14, 2009, 03:57:11 PM »
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()...