Here is a full example settings page, using the tools from above. A real settings page will often be much larger than this, but the basics are the same.
Example 2.11. An example module settings.php script
<?php if (!defined("PHORUM_ADMIN")) return; // If data is posted, then store the posted settings in the database. if (count($_POST)) { $PHORUM['mod_foo']['field1'] = empty($_POST['field1']) ? 0 : 1; $PHORUM['mod_foo']['field2'] = (int) $_POST['field2']; // Do some error checking. if ($PHORUM['mod_foo']['field2'] > 1000) { phorum_admin_error("The value for field 2 is too high!"); } // The data was okay. Store the settings. else { phorum_db_update_settings(array("mod_foo" => $PHORUM["mod_foo"])); phorum_admin_okmsg('The settings were saved successfully'); } } // This block is standard for every settings page. The "mod" field // must be set to the name of the module for which the settings // page is written. include_once "./include/admin/PhorumInputForm.php"; $frm = new PhorumInputForm ("", "post", "Submit this form"); $frm->hidden("module", "modsettings"); $frm->hidden("mod", "foo"); // Add a header row to the form. $frm->addbreak("Foo module settings"); // Add a checkbox to the form. $row = $frm->addrow( "Field 1", $frm->checkbox("field1", "1", "Yes", $PHORUM['mod_foo']['field1']) ); // Add a help balloon to Field 1. $frm->addhelp( $row, "Field 1", "This is a help balloon text for Field 1." ); // Add a text field to the form. $frm->addrow( "Field 2", $frm->text_box("field2", $PHORUM['mod_foo']['field2'], 50) ); // Display the form. $frm->show(); ?>