You are here

function _content_sort_items in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 content.module \_content_sort_items()
  2. 6 content.module \_content_sort_items()

Helper function to sort items in a field according to user drag-n-drop reordering.

2 calls to _content_sort_items()
content_add_more_js in includes/content.node_form.inc
Menu callback for AHAH addition of new empty widgets.
content_field in ./content.module
Implementation of hook_field(). Handles common field housekeeping.

File

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

Code

function _content_sort_items($field, $items) {
  if ($field['multiple'] >= 1 && isset($items[0]['_weight'])) {
    usort($items, '_content_sort_items_helper');
    foreach ($items as $delta => $item) {
      if (is_array($items[$delta])) {
        unset($items[$delta]['_weight']);
      }
    }
  }
  return $items;
}