Index: content.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.install,v retrieving revision 1.6 diff -u -F^f -r1.6 content.install --- content.install 28 Mar 2006 13:22:57 -0000 1.6 +++ content.install 10 Apr 2006 11:54:55 -0000 @@ -29,6 +29,8 @@ function content_install() { type_name varchar(32) NOT NULL default '', weight int NOT NULL default '0', label varchar(255) NOT NULL default '', + in_teaser bool default NULL, + in_body bool default NULL, widget_type varchar(32) NOT NULL default '', widget_settings mediumtext NOT NULL, description mediumtext NOT NULL, @@ -87,3 +89,20 @@ function content_update_2() { return $ret; } +function content_update_3() { + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'pgsql': + //TODO + break; + + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {node_field_instance} ADD COLUMN in_teaser bool default NULL"); + $ret[] = update_sql("ALTER TABLE {node_field_instance} ADD COLUMN in_body bool default NULL"); + break; + } + + return $ret; +} Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v retrieving revision 1.36 diff -u -F^f -r1.36 content.module --- content.module 9 Apr 2006 14:45:54 -0000 1.36 +++ content.module 10 Apr 2006 11:54:55 -0000 @@ -281,8 +281,10 @@ function content_delete(&$node) { * Implementation of hook_view(). */ function content_view(&$node, $teaser = FALSE, $page = FALSE) { - $node->body = implode('', _content_field_invoke('view', $node, FALSE, $page)); - $node->teaser = implode('', _content_field_invoke('view', $node, TRUE, $page)); + $bodies = _content_field_invoke('view', $node, FALSE, $page); + $node->body = implode('', $bodies['body']); + $teasers = _content_field_invoke('view', $node, TRUE, $page); + $node->teaser = implode('', $teasers['teaser']); $node->readmore = ($node->body != $node->teaser); } @@ -494,7 +515,7 @@ function _content_types($reset = FALSE) $type_result = db_query('SELECT * FROM {node_type} nt ORDER BY nt.type_name ASC'); while ($type = db_fetch_object($type_result)) { $type->fields = array(); - $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description, nf.type, nf.global_settings, nf.required, nf.multiple FROM {node_field_instance} nfi LEFT JOIN {node_field} nf ON nfi.field_name = nf.field_name WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type->type_name); + $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description, nfi.in_teaser, nfi.in_body, nf.type, nf.global_settings, nf.required, nf.multiple FROM {node_field_instance} nfi LEFT JOIN {node_field} nf ON nfi.field_name = nf.field_name WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type->type_name); while ($field = db_fetch_array($field_result)) { $field_settings = $field['global_settings'] ? unserialize($field['global_settings']) : array(); $widget_settings = $field['widget_settings'] ? unserialize($field['widget_settings']) : array(); Index: content_admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_admin.inc,v retrieving revision 1.7 diff -u -F^f -r1.7 content_admin.inc --- content_admin.inc 9 Apr 2006 14:45:54 -0000 1.7 +++ content_admin.inc 10 Apr 2006 11:54:56 -0000 @@ -157,7 +157,7 @@ function _content_admin_type_edit_submit if (isset($form_values['original_type_name'])) { // Duplicate the field structure from the old content type. - db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings) SELECT field_name, '%s', weight, label, widget_type, widget_settings FROM {node_field_instance} WHERE type_name = '%s'", $form_values['type_name'], $form_values['original_type_name']); + db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, in_teaser, in_body) SELECT field_name, '%s', weight, label, widget_type, widget_settings, in_teaser, in_body FROM {node_field_instance} WHERE type_name = '%s'", $form_values['type_name'], $form_values['original_type_name']); } drupal_set_message(t('Saved content type %type.', array('%type' => theme('placeholder', $form_values['label'])))); @@ -347,7 +347,7 @@ function theme_content_admin_field_add_n * Add an existing field to a content type. */ function _content_admin_field_add_existing_submit($form_id, $form_values) { - $prior_instance = db_fetch_object(db_query("SELECT weight, label, widget_type, widget_settings FROM {node_field_instance} WHERE field_name = '%s'", $form_values['field_name'])); + $prior_instance = db_fetch_object(db_query("SELECT weight, label, widget_type, widget_settings, in_teaser, in_body FROM {node_field_instance} WHERE field_name = '%s'", $form_values['field_name'])); if (!$prior_instance) { $prior_instance = new stdClass(); $prior_instance->weight = 0; @@ -355,7 +355,7 @@ function _content_admin_field_add_existi $prior_instance->widget_type = ''; $prior_instance->widget_settings = ''; } - db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings) VALUES ('%s', '%s', %d, '%s', '%s', '%s')", $form_values['field_name'], $form_values['type_name'], $prior_instance->weight, $prior_instance->label, $prior_instance->widget_type, $prior_instance->widget_settings); + db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, in_teaser, in_body) VALUES ('%s', '%s', %d, '%s', '%s', '%s')", $form_values['field_name'], $form_values['type_name'], $prior_instance->weight, $prior_instance->label, $prior_instance->widget_type, $prior_instance->widget_settings, $prior_instance->in_teaser, $prior_instance->in_body); drupal_set_message(t('Added field %label.', array('%label' => theme('placeholder', $prior_instance->label)))); content_clear_type_cache(); @@ -503,6 +503,40 @@ function _content_admin_field($type_name '#default_value' => $field['widget']['weight'], '#description' => t('In the node editing form, the heavier fields will sink and the lighter fields will be positioned nearer the top.'), ); + $form['widget']['in_teaser'] = array( + '#type' => 'checkbox', + '#title' => t('Teaser'), + '#default_value' => $field['in_teaser'], + '#description' => t('Show this field in the teasers.'), + ); + $form['widget']['in_body'] = array( + '#type' => 'checkbox', + '#title' => t('Body'), + '#default_value' => $field['widget'] ? $field['in_body'] : TRUE, + '#description' => t('Show this field in the full page views (in the body).'), + ); + $additions = module_invoke($widget_type['module'], 'widget_settings', 'form', $field['widget']); if (is_array($additions)) { $form['widget'] = array_merge($form['widget'], $additions); @@ -598,21 +642,23 @@ function _content_admin_field_submit($fo } } - $prev_field = $field; - $prev_columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $field); - - db_query("UPDATE {node_field_instance} SET weight = %d, label = '%s', widget_type = '%s', widget_settings = '%s', description = '%s' WHERE type_name = '%s' AND field_name = '%s'", $form_values['weight'], $form_values['label'], $form_values['widget_type'], serialize($widget_settings), $form_values['description'], $form_values['type_name'], $form_values['field_name']); + db_query("UPDATE {node_field_instance} SET weight = %d, label = '%s', widget_type = '%s', widget_settings = '%s', in_teaser = %s, in_body = %d, description = '%s' WHERE type_name = '%s' AND field_name = '%s'", $form_values['weight'], $form_values['label'], $form_values['widget_type'], serialize($widget_settings), $form_values['in_teaser'], $form_values['in_body'], $form_values['description'], $form_values['type_name'], $form_values['field_name']); db_query("UPDATE {node_field} SET required = %d, multiple = %d, global_settings = '%s' WHERE field_name = '%s'", $form_values['required'], $form_values['multiple'], serialize($field_settings), $form_values['field_name']); drupal_set_message(t('Saved field %field.', array('%field' => theme('placeholder', $form_values['label'])))); content_clear_type_cache(); + $prev_field = $field; + $prev_columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $field); + $fields = _content_fields(); $new_field = $fields[$form_values['field_name']]; $new_columns = module_invoke($field_type['module'], 'field_settings', 'database columns', $new_field); - content_alter_db_field($prev_field, $prev_columns, $new_field, $new_columns); + if (is_array($prev_columns) && is_array($new_columns)) { + content_alter_db_field($prev_field, $prev_columns, $new_field, $new_columns); + } drupal_goto('admin/node/types/'. $form_values['type_name'] .'/fields'); }