function hook_field_weight_display_overview_weights_alter in Field display weights (per node) 7.2
Parameters
$weight_instances The database-stored Field Weight configurations.: Change these if you want the fields to display in a different order.
$context An associative array containing the following::
- 'highest weight': By-reference parameter to change the basis used for
weight deltas.
- 'original instances': The field instances from the content type.
- 'original weights': The database-stored weight order for the node.
- 'revision weights': The database-stored weight order for the revision.
This is often the same as $context['original weights'], but if the load function fell back to the published node due to the revision not having any weights set, this will be empty. That may happen if the user clicks the Reset button on the revision.
- 'node': The node whose weights we are rearranging.
1 function implements hook_field_weight_display_overview_weights_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
File
- ./
field_weight.api.php, line 17
Code
function hook_field_weight_display_overview_weights_alter(&$weight_instances, &$context) {
// See if any field weights have been set.
if (empty($context['original weights'])) {
// OK, then we want to swap in the parent node's weights and
// resort the instances accordingly.
if (!empty($context['node']->tnid)) {
$parent = node_load($context['node']->tnid);
$weights = field_weight_get_node_weight($parent->vid);
if ($weights) {
list($weight_instances, $context['highest weight']) = field_weight_sort_instances($context['original instances'], $weights, $context['revision weights']);
// Go through the instances and add the 'new' key so that (unsaved)
// still shows up.
foreach ($weight_instances as &$weight_instance) {
$weight_instance['new'] = TRUE;
}
}
}
}
}