+ # 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~);<!--~}~--><!--~pulldowns once_if {~-->
+<!--~}~--><!--~opt_db {~-->
+ if($id) {
+ # add hidden field for database id of row we're editing
+ tem_set('~file_name~_edit_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.');