content_migrate.install in Content Construction Kit (CCK) 7.3
File
modules/content_migrate/content_migrate.install
View source
<?php
function content_migrate_install() {
foreach (node_type_get_names() as $type_name => $label) {
$bundle_settings = field_bundle_settings('node', $type_name);
$bundle_settings += array(
'extra_fields' => array(
'form' => array(),
'display' => array(),
),
'view_modes' => array(),
);
$weights = variable_get('content_extra_weights_' . $type_name, array());
if (empty($weights) || !array_key_exists('body_field', $weights)) {
$bundle_settings['extra_fields']['form']['body'] = array(
'weight' => 0,
);
}
foreach ($weights as $field => $weight) {
switch ($field) {
case 'body_field':
$new_field = 'body';
break;
default:
$new_field = $field;
break;
}
$bundle_settings['extra_fields']['form'][$new_field] = array(
'weight' => $weight,
);
}
$body_weight = !empty($weights['body_field']) ? $weights['body_field'] : 0;
$instance = field_info_instance('node', 'body', $type_name);
if (!empty($instance)) {
$instance['widget']['weight'] = $body_weight;
foreach ($instance['display'] as $context => $format) {
$instance['display'][$context]['weight'] = $body_weight;
}
field_update_instance($instance);
}
field_bundle_settings('node', $type_name, $bundle_settings);
}
field_info_cache_clear();
}
Functions
Name |
Description |
content_migrate_install |
Transfer weights from the D6 Manage Fields screen
to the D7 stored settings array. Do this once only, on install,
so later changes to these values in the Field UI screen will
not be overwritten. |