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

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

Scheduled Pinned Locked Moved Development
2 Posts 2 Posters 3.0k Views
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 Mar 22, 2006, 12:23 PM

    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 Mar 22, 2006, 4:16 PM

      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
      1 out of 2
      • First post
        1/2
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
        This community forum collects and processes your personal information.
        consent.not_received