You are here

function commons_update_3114 in Drupal Commons 7.3

Automatically use field_title for all nodes instead of the node base title.

File

./commons.install, line 748
Install, update and uninstall functions for the Commons install profile.

Code

function commons_update_3114() {
  variable_set('title_node', array(
    'auto_attach' => array(
      'title' => 'title',
    ),
    'hide_label' => array(
      'page' => 0,
      'entity' => 0,
    ),
  ));
  foreach (node_type_get_types() as $node_type) {

    // Set the title as "Replaced by title_field".
    if (!title_field_replacement_enabled('node', $node_type->type, 'title')) {
      title_field_replacement_toggle('node', $node_type->type, 'title');
    }

    // Migrate the titles to the title field.
    title_field_replacement_batch_set('node', $node_type->type, 'title');
  }
  drupal_flush_all_caches();
}