I would like to create a plugin which will put in dedicated tables the different values of some field (title, authors, etc). I need to have all the values of these fields to create a special form.
I thought that a plugin could insert the values into the tables with the SchemaPlugin::indexRecord hook. I began to write that plugin. I managed to create the plugin: it appears in the site administration, and I enabled it.
But it doesn’t do anything. I insert new records, but nothing happens: no file is created, no error message, nothing.
Here is essential extract of the code I wrote:
- Code: Select all
class eePlugin extends GenericPlugin {
function register($category, $path) {
$result = parent::register($category, $path);
if ($result) {
HookRegistry::register('SchemaPlugin::indexRecord', array(&$this, 'saveValues'));
}
return $result;
}
/**
* Save field values in dedicated tables
*/
function saveValues($hookName, $args)
{
$archive =& $args[0];
$record =& $args[1];
$field =& $args[2];
$value =& $args[3];
$attributes =& $args[4];
$fp = fopen('/tmp/data.txt', 'w+');
fwrite($fp, "$archive \n");
fwrite($fp, "$record \n");
fwrite($fp, "$field \n");
fwrite($fp, "$value \n");
fwrite($fp, "$attributes \n");
fclose($fp);
return false;
}
/* cut */
}
Any help is welcome,
