function ctools_content_render in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/content.inc \ctools_content_render()
Get the content from a given content type.
Parameters
$type: The content type. May be the name or an already loaded content type plugin.
$subtype: The name of the subtype being rendered.
$conf: The configuration for the content type.
$keywords: An array of replacement keywords that come from outside contexts.
$args: The arguments provided to the owner of the content type. Some content may wish to configure itself based on the arguments the panel or dashboard received.
$context: An array of context objects available for use.
$incoming_content: Any incoming content, if this display is a wrapper.
Return value
The content as rendered by the plugin. This content should be an array with the following possible keys:
- title: The safe to render title of the content.
- content: The safe to render HTML content.
- links: An array of links associated with the content suitable for theme('links').
- more: An optional 'more' link (destination only)
- admin_links: Administrative links associated with the content, suitable for theme('links').
- feeds: An array of feed icons or links associated with the content. Each member of the array is rendered HTML.
- type: The content type.
- subtype: The content subtype. These two may be used together as module-delta for block style rendering.
File
- includes/
content.inc, line 269 - Contains the tools to handle pluggable content that can be used by other applications such as Panels or Dashboard.
Code
function ctools_content_render($type, $subtype, $conf, $keywords = array(), $args = array(), $context = array(), $incoming_content = '') {
if (is_array($type)) {
$plugin = $type;
}
else {
$plugin = ctools_get_content_type($type);
}
$subtype_info = ctools_content_get_subtype($plugin, $subtype);
$function = ctools_plugin_get_function($subtype_info, 'render callback');
if (!$function) {
$function = ctools_plugin_get_function($plugin, 'render callback');
}
if ($function) {
$pane_context = ctools_content_select_context($plugin, $subtype, $conf, $context);
if ($pane_context === FALSE) {
return;
}
$content = $function($subtype, $conf, $args, $pane_context, $incoming_content);
if (empty($content)) {
return;
}
// Set up some defaults and other massaging on the content before we hand
// it back to the caller.
if (!isset($content->type)) {
$content->type = $plugin['name'];
}
if (!isset($content->subtype)) {
$content->subtype = $subtype;
}
// Override the title if configured to
if (!empty($conf['override_title'])) {
// Give previous title as an available substitution here.
$keywords['%title'] = empty($content->title) ? '' : $content->title;
$content->original_title = $keywords['%title'];
$content->title = $conf['override_title_text'];
}
if (!empty($content->title)) {
// Perform substitutions
if (!empty($keywords) || !empty($context)) {
$content->title = ctools_context_keyword_substitute($content->title, $keywords, $context);
}
// Sterilize the title
$content->title = filter_xss_admin($content->title);
// If a link is specified, populate.
if (!empty($content->title_link)) {
if (!is_array($content->title_link)) {
$url = array(
'href' => $content->title_link,
);
}
else {
$url = $content->title_link;
}
// set defaults so we don't bring up notices
$url += array(
'href' => '',
'attributes' => NULL,
'query' => NULL,
'fragment' => NULL,
'absolute' => NULL,
'html' => TRUE,
);
$content->title = l($content->title, $url['href'], $url);
}
}
return $content;
}
}