function noderelationships_get_element_weight in Node Relationships 6
Obtain the default weight for a new CCK "Manage fields" element.
See content_field_overview_form() in cck/includes/content.admin.inc.
Parameters
$nodetype: The node type.
Return value
An integer with the element weight.
3 calls to noderelationships_get_element_weight()
- noderelationships_cck_backref_create in ./
noderelationships.inc - Create a back reference field.
- noderelationships_content_extra_fields in ./
noderelationships.module - Implementation of hook_content_extra_fields().
- _noderelationships_nodeapi_view in ./
noderelationships.pages.inc - Implementation of hook_nodeapi('view').
File
- ./
noderelationships.inc, line 676 - Common functions for the noderelationships module.
Code
function noderelationships_get_element_weight($nodetype) {
$weights = array();
if (module_exists('fieldgroup')) {
foreach (fieldgroup_groups($nodetype) as $group) {
$weights[] = $group['weight'];
}
}
$content_type = content_types($nodetype);
foreach ($content_type['fields'] as $field) {
$weights[] = $field['widget']['weight'];
}
return !empty($weights) ? max($weights) + 1 : 1;
}