function ctools_content_get_subtype in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/content.inc \ctools_content_get_subtype()
Given a content type and a subtype id, return the information about that content subtype.
Parameters
$type: The content type being fetched.
$subtype_id: The id of the subtype being fetched.
Return value
An array of information describing the content subtype.
2 calls to ctools_content_get_subtype()
- ctools_content_render in includes/
content.inc - Get the content from a given content type.
- ctools_content_select_context in includes/
content.inc - Select the context to be used for a piece of content, based upon config.
File
- includes/
content.inc, line 191 - Contains the tools to handle pluggable content that can be used by other applications such as Panels or Dashboard.
Code
function ctools_content_get_subtype($type, $subtype_id) {
$subtype = array();
if (is_array($type)) {
$plugin = $type;
}
else {
$plugin = ctools_get_content_type($type);
}
$function = ctools_plugin_get_function($plugin, 'content type');
if ($function) {
$subtype = $function($subtype_id, $plugin);
}
else {
$subtypes = ctools_content_get_subtypes($type);
if (isset($subtypes[$subtype_id])) {
$subtype = $subtypes[$subtype_id];
}
// If there's only 1 and we somehow have the wrong subtype ID, do not
// care. Return the proper subtype anyway.
if (empty($subtype) && !empty($plugin['single'])) {
$subtype = current($subtypes);
}
}
if ($subtype) {
ctools_content_prepare_subtype($subtype, $plugin);
}
return $subtype;
}