Navigation

    Netgate Discussion Forum
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    Adding options to the web interface of a package - howto?

    Development
    2
    2
    2756
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yanl last edited by

      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.conf

      So 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?

      1 Reply Last reply Reply Quote 0
      • S
        sullrich last edited by

        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";
        }

        1 Reply Last reply Reply Quote 0
        • First post
          Last post