function 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 184

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) {
        // Ensure that the 'subtype_id' value exists. This is also done in
        // ctools_content_get_subtypes(), but it wouldn't be called if the plugin
        // provides the subtype through its own function.
        if (!isset($subtype['subtype_id'])) {
            $subtype['subtype_id'] = $subtype_id;
        }
        ctools_content_prepare_subtype($subtype, $plugin);
    }
    return $subtype;
}