- if(!$edit_id) {<!--~opt_listing_1 start~-->
- if(!isset($_REQUEST['~form_name~_new']) && !isset($_REQUEST['~always_field~'])) {
- if(~form_name~_display_listing()) {
- return;
- }
- }
- <!--~end~-->
- tem_sub('new_msg');
- }<!--~end~-->
-
- if(isset($_REQUEST['~always_field~'])) {
- list(~php_fields~) = ~form_name~_get_fields();
-
- if("you're happy with the POSTed values") {<!--~opt_db_4 start~-->
- if($edit_id) {<!--~image_db start~-->
- # uploading nothing means leaving it as is.
- if(!$~name~ && $delete_~name~ != 'Yes') {
- $~name~ = db_get_value('~form_name~', '~name~', 'where id=%i', $edit_id);
- }
- <!--~end~-->
- db_update('~form_name~', ~form_name.upper~_DB_FIELDS, ~php_fields~, 'where id=%i', $edit_id);
- message('Entry updated.');
+ # default action:
+ return ~file_name~_main_listing();~}~~opt_listing unset {~
+ return ~file_name~_main_form();~}~
+}~opt_display {~
+
+function ~file_name~_main_display($id) {
+ $data = db_get_assoc('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'where id=%i', $id);
+ if(!$data) {
+ message("Error: Broken Link (~singular cap~ #$id not found)");~opt_public_something {~
+ return './' . $GLOBALS['wfpl_basename'];~}~~opt_public_something unset {~
+ return './~file_name~';~}~
+ }
+ tem_set('display', $data);
+}~}~~opt_db {~
+
+function ~file_name~_main_delete($id) {
+ db_delete('~table_name~', 'where id=%i', $id);
+ message('~singular cap~ deleted.');
+ return './~file_name~';
+}~}~~opt_listing {~
+
+function ~file_name~_main_listing() {
+ $listing_rows = db_get_assocs('~table_name~', 'id~listing_fields_1 {~,~name~~}~', 'order by ~always_field~ limit 100');
+ tem_set('listings', $listing_rows);
+}~}~
+
+function ~file_name~_main_form($id = false) {~pulldowns {~
+ pulldown('~name~', ~pulldown_options~);~}~~has_pulldowns {~
+~}~~opt_db {~
+ if($id) {
+ # add hidden field for database id of row we're editing
+ tem_set('id', $id);
+ tem_set('editing');
+ tem_set('edit_msg');
+ } else {
+ tem_set('new_msg');
+ }
+~}~
+ if(isset($_POST['~always_field~'])) {
+ $data = ~file_name~_get_fields();
+
+ if("you're happy with the POSTed values") {~opt_db {~
+ if($id) {
+ db_update_assoc('~table_name~', $data, 'where id=%i', $id);
+ message('~singular cap~ updated.');