The function _content_type_info() returns all information of all fields including of shared fields correctly (one array of one field for each content type). Instead content_field() only returns the data of the last content type.
Is there another function CCK provides which enables the developer to retrieve all content types/widgets of a specified field (in my case I need all labels that field has)? Currently I use _content_type_info() and filter the result for the fieldname.
Comments
Comment #1
yched commentedcontent_field($field_name, $type_name);provides the information for the field instance in a given type.It fetches from the cached data built by
_content_type_info()(no db hit).content_field_instance_read(array('field_name' => $field_name));will provide an array of all the field instances for a given field.Each call queries the content_node_field and content_node_field_instance tables - not cached.
function is defined in cck/includes/content.crud.inc, you'll have to manually include the file before calling the function.
Comment #2
Roi Danton commentedThanks for the quick answer!
Though
content_field_instance_readworks fine I stick to_content_type_info()due cached data is enough for me. If someone else wants to do this, too: