-function ~form_name~() {<!--~opt_http_pass_2 start~-->
- # To remove password protection, just delete this block:
- if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != AUTH_USER || $_SERVER['PHP_AUTH_PW'] != AUTH_PASS) {
- header('WWW-Authenticate: Basic realm="' . AUTH_REALM . '"');
- header('HTTP/1.0 401 Unauthorized');
- echo '401 Unauthorized';
- exit;
+<!--~opt_listing_2 {~-->
+# You may pass a "where clause" for the db query.
+function ~file_name~_display_listing($where = 'order by ~always_field~ limit 100') {
+ $rows = db_get_assocs('~table_name~', 'id<!--~listing_fields_1 {~-->,~name~<!--~}~-->', $where);
+ if($rows == false || count($rows) == 0) {
+ tem_set('listings', array('empty_listing' => true));
+ return;
+ }
+
+ # make sure there's something clickable
+ foreach($rows as &$row) {
+ if($row['~always_field~'] == '') {
+ $row['~always_field~'] = '--';
+ }
+ }
+ tem_set('listings', array(
+ 'populated_listing' => true,
+ 'rows' => $rows));
+ return true;
+}
+<!--~}~-->
+function ~file_name~_main() {<!--~opt_pass {~-->
+ if(!logged_in_as_admin()) {
+ $GLOBALS['url'] = this_url();
+ return 'admin_login';
+ }
+<!--~}~--><!--~opt_display_1 {~-->
+ if(isset($_REQUEST['~file_name~_id'])) {
+ return ~file_name~_display_main();
+ } else {
+ return ~file_name~_edit_main();