I'm working on a plugin that needs to store a URL. Plugin: is returning a blank object with nearly no data in it.

so in my config.php file I've got the following php:

return array (

'url' => new TextboxField ( array (

'id' => 'timetrex_url',

'label' => 'Enter the url of your timetrex installation',

'configuration' => array (

'desc' => 'Enter the url of your timetrex installation',

'length'=>400,

'size'=>100 )

) ),

and in my instantiated plugin i've got this:

function getURL(){

return $this->getConfig()->get('timetrex_url');

}

It was working, but then I changed some file names during dev. I've been trying to figure it out but getConfig is returning a new instance of config with zero data in it. Anyone know why? Anyone know how to fix it?

MORE INFO: I am instantiating the plugin manually to call some render code in the <head> section I've noticed that I'm missing an ID as the constructor argument. This same Id argument is used to select the config during getConfig(). What should the constructor's argument be?

UPDATE & SOLUTION: The issue was that I was instantiating the plugin with no ID. this override of the constructor fixes my problem and gives access to the plugin's data as expected. function __construct(){

//first we need to get the id of the plugin

$sql = 'SELECT id FROM '.PLUGIN_TABLE

.' WHERE install_path="plugins/TTpunchbutton"';

$id = db_result(db_query($sql));

parent:($id);

}

a month later

I don't understand.  Where did you put the __construct code at?  Hopefully this isn't too old a thread.

Write a Reply...