Difference between revisions of "PLG configChange"

From GeeklogWiki
Jump to: navigation, search
(PLG_configChange)
 
m (PLG_getItemInfo seems somewhat related ...)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This API function informs plugins about configuration changes:
 
This API function informs plugins about configuration changes:
  
<pre>function PLG_configChange($group, $changes)</pre>
+
<pre>function PLG_configChange($group, $changes = array())</pre>
  
where <code>$group</code> is either <tt>'Core'</tt> for changes in the core configuration (i.e. the global <code>$_CONF</code> array) or the name of the plugin. Note that plugins are only notified of changes in Core or their own configuration. Plugins will ''not'' be notified of changes in the configuration of other plugins.
+
where <code>$group</code> is either <tt>'Core'</tt> for changes in the core configuration (i.e. the global <code>$_CONF</code> array) or the name of a plugin.
  
<code>$changes</code> is an array of names of the config values that changed, i.e. keys of <code>$_CONF</code> or the plugin's own configuration array.
+
<code>$changes</code> is an array of names of the config values that changed, i.e. keys of <code>$_CONF</code> or the plugin's own configuration array. Note that this parameter is ''optional''.
  
 
For example: For a plugin 'foo', a change in <code>$_CONF['path']</code> and <code>$_CONF['site_mail']</code> would result in a function call like this:
 
For example: For a plugin 'foo', a change in <code>$_CONF['path']</code> and <code>$_CONF['site_mail']</code> would result in a function call like this:
  
 
<pre>plugin_configchange_foo('Core', array('path', 'site_mail'));</pre>
 
<pre>plugin_configchange_foo('Core', array('path', 'site_mail'));</pre>
 +
 +
 +
'''Note:''' Details about the changes will only be passed on for changes in the Core configuration and for changes in the plugin's own configuration. Plugins will ''not'' be notified of the details of changes in other plugins (only about the fact that the configuration of that other plugin changed). This should be considered an "educational measure" so as not to make plugins depend on the internals of other plugins.
 +
 +
For example, when the 'test' configuration option of plugin 'bar' changes, the plugin 'foo' will be called like so:
 +
 +
<pre>plugin_configchange_foo('bar');</pre>
 +
 +
while the 'bar' plugin itself will receive a call like so:
 +
 +
<pre>plugin_configchange_bar('bar', array('test'));</pre>
 +
 +
== Also see ==
 +
 +
* [[PLG_getItemInfo]]
  
  
 
[[Category:Plugin Development]]
 
[[Category:Plugin Development]]

Latest revision as of 11:26, 4 June 2009

This API function informs plugins about configuration changes:

function PLG_configChange($group, $changes = array())

where $group is either 'Core' for changes in the core configuration (i.e. the global $_CONF array) or the name of a plugin.

$changes is an array of names of the config values that changed, i.e. keys of $_CONF or the plugin's own configuration array. Note that this parameter is optional.

For example: For a plugin 'foo', a change in $_CONF['path'] and $_CONF['site_mail'] would result in a function call like this:

plugin_configchange_foo('Core', array('path', 'site_mail'));


Note: Details about the changes will only be passed on for changes in the Core configuration and for changes in the plugin's own configuration. Plugins will not be notified of the details of changes in other plugins (only about the fact that the configuration of that other plugin changed). This should be considered an "educational measure" so as not to make plugins depend on the internals of other plugins.

For example, when the 'test' configuration option of plugin 'bar' changes, the plugin 'foo' will be called like so:

plugin_configchange_foo('bar');

while the 'bar' plugin itself will receive a call like so:

plugin_configchange_bar('bar', array('test'));

Also see