content_extra_field_weight

Definition

content_extra_field_weight($type_name, $pseudo_field_name)
modules/cck/content.module, line 2345

Description

Retrieve the user-defined weight for non-CCK node 'fields'.

CCK's 'Manage fields' page lets users reorder node fields, including non-CCK items (body, taxonomy, other hook_nodeapi-added elements by contrib modules...). Contrib modules that want to have their 'fields' supported need to expose them with hook_content_extra_fields, and use this function to retrieve the user-defined weight.

Parameters

$type_name The content type name.

$pseudo_field_name The name of the 'field'.

Return value

The weight for the 'field', respecting the user settings stored by content.module.

Code

<?php
function content_extra_field_weight($type_name, $pseudo_field_name) {
  $type = content_types($type_name);

  // If we don't have the requested item, this may be because the cached
  // information for 'extra' fields hasn't been refreshed yet.
  if (!isset($type['extra'][$pseudo_field_name])) {
    content_clear_type_cache();
  }

  if (isset($type['extra'][$pseudo_field_name])) {
    return $type['extra'][$pseudo_field_name]['weight'];
  }
}
?>