Possible to use variable values in Plugin code?
Hey there,
I built several custom plugins for a client, which connect to an external application to pull in and display some data. In the plugin, I've hard-coded the Login and Password needed to connect to the other system, and it works well.
But the client would like to be able to update the Login/Pass if needed, somewhere in the EE control panel, instead of editing the plugin code.
Probably not, but, can the Low Variable values be accessed somehow within plugin code? I know I could probably access this data if it were a Global Variable (set in path.php), but again, there's no way for them to update this without editing that file directly (right?).
Any info would be great, tx!
Replies
Low 15 Mar 2010 15:10
Hey Ira,
Actually, this is possible. Each variable with Early Parsing enabled is added to EE's native global variables array, which you can access with this code:
global $IN;
$IN->global_vars;
All you have to do is create two variables for the username and password, enable early parsing for each of them, and you'll be able to use them throughout the site, including your custom add-ons.
ira42 15 Mar 2010 17:18
Sweet baby Jebus, that's good news!
Thanks for the info, and for the addon. Going to purchase this asap!
Cheers,
Ira