You are here

function content_alter_extra_weights in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6.2 content.module \content_alter_extra_weights()

Pre-render callback to adjust weights of non-CCK fields.

2 string references to 'content_alter_extra_weights'
content_form_alter in ./content.module
Implementation of hook_form_alter().
content_nodeapi in ./content.module
Implementation of hook_nodeapi().

File

./content.module, line 456
Allows administrators to associate custom fields to content types.

Code

function content_alter_extra_weights($elements) {
  if (isset($elements['#content_extra_fields'])) {
    foreach ($elements['#content_extra_fields'] as $key => $value) {

      // Some core 'fields' use a different key in node forms and in 'view'
      // render arrays. Check we're not on a form first.
      if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
        $elements[$value['view']]['#weight'] = $value['weight'];
      }
      elseif (isset($elements[$key])) {
        $elements[$key]['#weight'] = $value['weight'];
      }
    }
  }
  return $elements;
}