Adding options to the web interface of a package - howto?
-
Hi,
I have some difficulties adding an option to squid's web interface (or any other packages).
Just for testing purpose, I would like to have a checkbox that let me add or remove a comment line in squid.confSo far, I've modify these two files:
"/usr/local/pkg/squid_ng.xml"
<fields>…
<field><fielddescr>Add a comment</fielddescr>
<fieldname>testing_enabled</fieldname>
<description>Some testing stuff.</description>
<type>checkbox</type></field>
...</fields>"/usr/local/pkg/squid_ng.inc"
function global_write_squid_config() {...
$testing_enabled = $config['installedpackages']['squid']['config'][0]['testing_enabled'];
…
if (isset($testing_enabled) && ($testing_enabled == "on")) {
$config_array[] = "# This is a test.\n";
}...
}
The comment line is add to squid.conf but is never removed when I uncheck the checkbox, and in /cf/conf/config.xml, "<testing_enabled></testing_enabled>" is always set to "on".
What did I miss?
-
you need to unset() the variable before doing the test. That way its already deleted if the user does not enable the option.
$testing_enabled = $config['installedpackages']['squid']['config'][0]['testing_enabled'];
unset($config['installedpackages']['squid']['config'][0]['testing_enabled']);
write_config():
if (isset($testing_enabled) && ($testing_enabled == "on")) {
$config_array[] = "# This is a test.\n";
}