--- faq.module 2006-06-09 00:51:46.000000000 -0700 +++ faq.module 2006-06-09 00:51:09.000000000 -0700 @@ -28,8 +28,8 @@ /** * Implementation of hook_node_name() */ -function faq_node_name(){ - return 'faq'; +function faq_node_info(){ + return array('faq' => array('name' => 'faq', 'base' => 'faq')); } /** @@ -58,12 +58,29 @@ for($i = -10; $i <= 10; $i++){ $values[$i] = $i; } - $output .= form_select(t('Weight'), 'weight', isset($node->weight) ? $node->weight : '0', $values); - foreach(taxonomy_node_form('faq', $node) as $vocab){ - $output .= $vocab; - } - $output .= form_textarea(t('Answer'), 'body', $node->body, 60, 20, 'Enter the answer to the question given in the title.', NULL, TRUE); - return $output; + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#size' => 60, + '#maxlength' => 128, + '#required' => TRUE, + '#default_value' => $node->title + ); + $form['weight'] = array( + '#title' => 'Weight', + '#options' => $values, + '#default_value' => isset($node->weight) ? $node->weight : '0' + ); + $form['body'] = array( + '#type' => 'textarea', + '#title' => t('Answer'), + '#description' => t('Enter the answer to the question given in the title.'), + '#default_value' => $node->body, + '#cols' => 60, + '#rows' => 20, + '#required' => TRUE + ); + return $form; } /** @@ -242,8 +259,7 @@ function theme_faq_get_faqs_for_term($term){ $found = false; $output = ''; - $title = '

' . $term->name . ' FAQ

' . "\n"; - $result = db_query('SELECT n.nid, n.title, n.body FROM {node} n, {term_node} t, {faq} f WHERE t.nid = n.nid AND f.fid = n.nid AND n.type="faq" AND n.status=1 AND t.tid = %d ORDER BY f.weight, n.title', $term->tid); + $result = db_query('SELECT n.nid, n.title, r.body FROM {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid, {term_node} t, {faq} f WHERE t.nid = n.nid AND f.fid = n.nid AND n.type="faq" AND n.status=1 AND t.tid = %d ORDER BY f.weight, n.title', $term->tid); $links = '' . "\n"; @@ -285,4 +301,16 @@ } } +function faq_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + db_query("CREATE TABLE {faq} ( + fid int(10) unsigned zerofill NOT NULL default '0000000000', + weight int(4) default '0', + PRIMARY KEY (fid) + ) TYPE=MyISAM;"); + break; + } +} + ?>