1 austriaco Mar 24, 2009 08:30
3 sam2kb Mar 25, 2009 02:18
if( ($Some_Plugin = & $Plugins->get_by_code('some_code')) !== false )
{
if( $Some_Plugin->status == 'enabled' )
{ // Plugin is installed and enabled
echo $Some_Plugin->Settings->get('some_setting');
}
}
;)
4 austriaco Mar 25, 2009 10:04
Hi sam,
That's almost there. The problem is that I'm not trying to access a Setting from the another plugin, but an internal variable.
See, the second plugin mantains a static variable inside one of its functions, which holds the number of times it has rendered some content. I want to check that variable, not a setting.
Probably that's not possible unless the second plugin does export this variable or something like that. I don't know if that's the proper terminology in the OO context we're speaking.
Corrections to my broken OO PHP lingo are welcome, of course.
5 sam2kb Mar 25, 2009 13:48
Plugin A
$my_var = 'qwerty';
$this->var = $my_var;
Plugin B
if( ($Some_Plugin = & $Plugins->get_by_code('some_code')) !== false )
{
if( $Some_Plugin->status == 'enabled' )
{ // Plugin is installed and enabled
echo $Some_Plugin->var;
}
}
This should work also
Not sure if it'll help or not, but if this is for personal use then you can look at your database and see the plugin ID for the first, then manually tell the second what to go look for. *probably*. I almost tried this then decided to jam everything into one 'mother of all plugins'.
Alternatively, dig on AM Current Plugins plugin via bopit. It builds itself a list of all plugins for displaying as a skintag, so it knows all sorts of stuff about installed plugins. That should get you well down the path of having plugin B talk to plugin A ... I think. Like, first plugin B needs to know plugin A is there, then know stuff like it's code and plugin_ID right?
To get database stuff would be real easy, which is what I thought of doing. One plugin to build the database tables and handle most data entry, the other to use that info and handle the data entry associated with posting. Anyway to get an internal variable, for me, would be next to impossible. I'd start with a whole bunch of stuff like
Then go back and add "global $Plugins after it choked until I finally figured out how to get all the way to plugin A and learn what it knows.
Or I'd wait for Yabba to make a plugin that talks to another plugin, then "steal with pride" the bits that didn't suck :)