function 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, or NULL. This content should be an object with the following possible properties:
- title: The safe to render title of the content.
- title_heading: The title heading.
- 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.
1 call to ctools_content_render()
- ctools_ajax_simple_form in ctools_ajax_sample/
ctools_ajax_sample.module
File
-
includes/
content.inc, line 273
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'];
$content->title_heading = isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2';
}
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' => array(),
'query' => array(),
'fragment' => '',
'absolute' => NULL,
'html' => TRUE,
);
$content->title = l($content->title, $url['href'], $url);
}
}
return $content;
}
}