--- excerpt.module.orig 2005-12-30 09:33:22.000000000 -0800 +++ excerpt.module.chud 2006-07-06 18:58:34.421875000 -0700 @@ -13,42 +13,64 @@ function excerpt_help($section) { function excerpt_nodeapi(&$node, $op, $arg) { switch ($op) { case 'validate': - if (trim($node->teaser) == '') { - $node->teaser = node_teaser($node->body); + $excerpt_node_types = variable_get('excerpt_node_types', node_get_types()); + if (in_array($node->type, $excerpt_node_types)) { + if (trim($node->teaser) == '') { + $node->teaser = node_teaser($node->body); + } } break; case 'view': - $node->readmore = $node->teaser != $node->body; + $excerpt_node_types = variable_get('excerpt_node_types', node_get_types()); + if (in_array($node->type, $excerpt_node_types)) { + $node->readmore = $node->teaser != $node->body; + } break; } } function excerpt_form_alter($form_id, &$form) { + if (isset($form['type'])) { $node = $form['#node']; - if ($form['type']['#value'] .'_node_settings' == $form_id) { - $form['excerpt'] = array('#type' => 'fieldset', '#title' => t('Excerpt')); - $form['excerpt']['excerpt_options_'. $form['type']['#value']] = array( - '#type' => 'radios', - '#title' => t('Teasers'), - '#default_value' => variable_get('excerpt_options_'. $form['type']['#value'], 1), - '#options' => array(t('Auto-generated'), t('Manual excerpt')), - '#description' => t('Choose whether teasers are generated automatically or can be entered manually by the author.') - ); - } + $excerpt_node_types = variable_get('excerpt_node_types', node_get_types()); + foreach($excerpt_node_types as $node_type) { - if ($form['type']['#value'] .'_node_form' == $form_id && variable_get('excerpt_options_'. $node->type, 1)) { - $form['teaser'] = array( - '#type' => 'textarea', - '#title' => t('Teaser'), - '#default_value' => $node->teaser, - '#cols' => 60, - '#rows' => 5, - '#weight' => -17.5, - '#description' => t('Enter an excerpt for this item. It will be shown on listing pages along with a read more link which leads to the full view. Leave empty to auto-generate one from the body.') - ); - } + if ($form_id == $node_type .'_node_settings') { + $form['excerpt'] = array('#type' => 'fieldset', '#title' => t('Excerpt')); + $form['excerpt']['excerpt_options_'. $form['type']['#value']] = array( + '#type' => 'radios', + '#title' => t('Teasers'), + '#default_value' => variable_get('excerpt_options_'. $form['type']['#value'], 1), + '#options' => array(t('Auto-generated'), t('Manual excerpt')), + '#description' => t('Choose whether teasers are generated automatically or can be entered manually by the author.') + ); + } + + if ($form_id == $node_type .'_node_form') { + $form['teaser'] = array( + '#type' => 'textarea', + '#title' => t('Teaser'), + '#default_value' => $node->teaser, + '#cols' => 60, + '#rows' => 5, + '#weight' => -3, + '#description' => t('Enter an excerpt for this item. It will be shown on listing pages along with a read more link which leads to the full view. Leave empty to auto-generate one from the body.') + ); + } + } } -} \ No newline at end of file +} + +function excerpt_settings() { + $form['excerpt_node_types'] = array( + '#type' => 'checkboxes', + '#title' => t('Display On'), + '#default_value' => variable_get('excerpt_node_types', $types), + '#options' => node_get_types(), + '#description' => t("Show teaser field on these content types."), + ); + return $form; +} \ No newline at end of file