Index: modules/node/node.css =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.css,v retrieving revision 1.8 diff -u -p -r1.8 node.css --- modules/node/node.css 4 Aug 2009 03:27:11 -0000 1.8 +++ modules/node/node.css 25 Aug 2009 09:34:05 -0000 @@ -21,6 +21,7 @@ td.revision-current { background: #ffc; } +.node-form .form-item .text, .node-form .form-text { display: block; width: 95%; Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.28 diff -u -p -r1.28 node.install --- modules/node/node.install 22 Aug 2009 00:58:54 -0000 1.28 +++ modules/node/node.install 25 Aug 2009 09:36:55 -0000 @@ -451,7 +451,7 @@ function node_update_7005() { } /** - * Convert body and teaser from node properties to fields, and migrate status/comment/promote/moderate and sticky columns to the {node_revision} table. + * Convert title, body and teaser from node properties to fields, and migrate status/comment/promote/moderate and sticky columns to the {node_revision} table. */ function node_update_7006(&$context) { $ret = array('#finished' => 0); @@ -463,9 +463,9 @@ function node_update_7006(&$context) { if (!isset($context['total'])) { // Initial invocation. - // Re-save node types to create body field instances. + // Re-save node types to create title and body field instances. foreach ($node_types as $type => $info) { - if ($info->has_body) { + if ($info->has_title || $info->has_body) { node_type_save($info); } } @@ -510,6 +510,7 @@ function node_update_7006(&$context) { 'vid' => $revision->vid, 'type' => $revision->type, ); + $node->title_field[FIELD_LANGUAGE_NONE][0]['value'] = $revision->title; if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) { $node->body[FIELD_LANGUAGE_NONE][0]['summary'] = $revision->teaser; } Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1111 diff -u -p -r1.1111 node.module --- modules/node/node.module 25 Aug 2009 02:48:16 -0000 1.1111 +++ modules/node/node.module 25 Aug 2009 09:34:05 -0000 @@ -202,25 +202,6 @@ function node_field_build_modes($obj_typ } /** - * Implement hook_field_extra_fields(). - */ -function node_field_extra_fields($bundle) { - $extra = array(); - - if ($type = node_type_get_type($bundle)) { - if ($type->has_title) { - $extra['title'] = array( - 'label' => $type->title_label, - 'description' => t('Node module element.'), - 'weight' => -5, - ); - } - } - - return $extra; -} - -/** * Gather a listing of links to nodes. * * @param $result @@ -551,6 +532,41 @@ function node_configure_fields($type) { field_delete_instance($instance); } + $field = field_info_field('title_field'); + if (empty($field)) { + $field = array( + 'field_name' => 'title_field', + 'type' => 'text', + ); + $field = field_create_field($field); + } + $instance = field_info_instance('title_field', $type->type); + if (empty($instance)) { + $instance = array( + 'field_name' => 'title_field', + 'bundle' => $type->type, + 'label' => $type->title_label, + 'widget_type' => 'text', + 'weight' => -5, + 'required' => TRUE, + + // With no UI in core, we have to define default + // formatters for the teaser and full view. + // This may change if the method of handling displays + // is changed or if a UI gets into core. + 'display' => array( + 'full' => array( + 'label' => 'hidden', + 'type' => 'hidden', + ), + 'teaser' => array( + 'label' => 'hidden', + 'type' => 'hidden', + ), + ), + ); + field_create_instance($instance); + } } /** @@ -967,6 +983,12 @@ function node_submit($node) { * omitted (or $node->is_new is TRUE), a new node will be added. */ function node_save($node) { + // For performance reasons we need to keep the node.title column, so we have + // to populate it with the title value. The language used is the node language + // as we don't need to care about possible translations in this case. + $language = empty($node->language) ? FIELD_LANGUAGE_NONE : $node->language; + $node->title = $node->title_field[$language][0]['value']; + field_attach_presave('node', $node); // Let modules modify the node before it is saved to the database. module_invoke_all('node_presave', $node); @@ -1265,7 +1287,7 @@ function template_preprocess_node(&$vari $variables['date'] = format_date($node->created); $variables['name'] = theme('username', $node); $variables['node_url'] = url('node/' . $node->nid); - $variables['title'] = check_plain($node->title); + $variables['title'] = check_plain(node_page_title($node)); $variables['page'] = (bool)menu_get_object(); if (!empty($node->in_preview)) { @@ -1874,7 +1896,8 @@ function node_menu() { * Title callback. */ function node_page_title($node) { - return $node->title; + $language = FIELD_LANGUAGE_NONE; + return $node->title_field[$language][0]['value']; } /** @@ -2905,29 +2928,6 @@ function _node_access_rebuild_batch_fini */ /** - * Implement hook_form(). - */ -function node_content_form($node, $form_state) { - - $type = node_type_get_type($node); - - $form = array(); - - if ($type->has_title) { - $form['title'] = array( - '#type' => 'textfield', - '#title' => check_plain($type->title_label), - '#required' => TRUE, - '#default_value' => $node->title, - '#maxlength' => 255, - '#weight' => -5, - ); - } - - return $form; -} - -/** * @} End of "defgroup node_content". */ Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.77 diff -u -p -r1.77 node.pages.inc --- modules/node/node.pages.inc 22 Aug 2009 14:34:20 -0000 1.77 +++ modules/node/node.pages.inc 25 Aug 2009 09:34:05 -0000 @@ -151,7 +151,7 @@ function node_form(&$form_state, $node) if ($extra = node_invoke($node, 'form', $form_state)) { $form = array_merge_recursive($form, $extra); } - if (!isset($form['title']['#weight'])) { + if (!isset($form['title_field']['#weight'])) { $form['title']['#weight'] = -5; }