summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--plugins/content_types/node/node.inc51
-rw-r--r--plugins/content_types/node_context/node_content.inc64
3 files changed, 92 insertions, 24 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index e970575..f7558b5 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -66,6 +66,7 @@ Restore a less aggressive plugin caching.
#827310: Node comments content type should not display comments if the node is configured to disable them.
#622570 by omerida: Add an option to display the comment forbidden information if the comment form cannot be displayed in comment form content type.
#863296: Do not leave NULL plugins left by searching for nonexistant plugins in the list when getting all plugins.
+#853256: Allow the normal node view content types to support CCK hosted build modes like Views does.
ctools 6.x-1.6 (2010-Jun-1)
==============
diff --git a/plugins/content_types/node/node.inc b/plugins/content_types/node/node.inc
index 81daf02..a2ba91b 100644
--- a/plugins/content_types/node/node.inc
+++ b/plugins/content_types/node/node.inc
@@ -16,10 +16,10 @@ $plugin = array(
'single' => TRUE,
'defaults' => array(
'nid' => '',
- 'teaser' => TRUE,
'links' => TRUE,
'leave_node_title' => FALSE,
'identifier' => '',
+ 'build_mode' => 'teaser',
),
'title' => t('Existing node'),
'icon' => 'icon_node.png',
@@ -93,11 +93,16 @@ function ctools_node_content_type_render($subtype, $conf, $panel_args) {
$node->panel_identifier = $conf['identifier'];
}
+ // Handle existing configurations with the deprecated 'teaser' option.
+ if (isset($conf['teaser'])) {
+ $conf['build_mode'] = $conf['teaser'] ? 'teaser' : 'full';
+ }
+
if (!isset($node->build_mode)) {
- $node->build_mode = NODE_BUILD_NORMAL;
+ $node->build_mode = ($conf['build_mode'] == 'teaser' || $conf['build_mode'] == 'full') ? NODE_BUILD_NORMAL : $conf['build_mode'];
}
- $block->content = node_view($node, $conf['teaser'], FALSE, $conf['links']);
+ $block->content = node_view($node, $conf['build_mode'] == 'teaser', FALSE, $conf['links']);
return $block;
}
@@ -141,12 +146,6 @@ function ctools_node_content_type_edit_form(&$form, &$form_state) {
);
}
- $form['teaser'] = array(
- '#title' => t('Show only node teaser'),
- '#type' => 'checkbox',
- '#default_value' => $conf['teaser'],
- );
-
$form['links'] = array(
'#type' => 'checkbox',
'#default_value' => $conf['links'],
@@ -160,6 +159,38 @@ function ctools_node_content_type_edit_form(&$form, &$form_state) {
'#description' => t('This identifier will be added as a template suggestion to display this node: node-panel-IDENTIFIER.tpl.php. Please see the Drupal theming guide for information about template suggestions.'),
);
+ // CCK holds the registry of available build modes, but can hardly
+ // push them as options for the build mode options, so we break the normal
+ // rule of not directly relying on non-core modules.
+ if ($modes = module_invoke('content', 'build_modes')) {
+ $build_mode_options = array();
+ foreach ($modes as $key => $value) {
+ if (isset($value['views style']) && $value['views style']) {
+ $build_mode_options[$key] = $value['title'];
+ }
+ }
+ }
+ else {
+ $build_mode_options = array(
+ 'teaser' => t('Teaser'),
+ 'full' => t('Full node')
+ );
+ }
+
+ // Handle existing configurations with the deprecated 'teaser' option.
+ // Also remove the teaser key from the form_state.
+ if (isset($conf['teaser']) || !isset($conf['build_mode'])) {
+ unset($form_state['conf']['teaser']);
+ $conf['build_mode'] = $conf['teaser'] ? 'teaser' : 'full';
+ }
+ $form['build_mode'] = array(
+ '#title' => t('Build mode'),
+ '#type' => 'select',
+ '#description' => t('Select a build mode for this node.'),
+ '#options' => $build_mode_options,
+ '#default_value' => $conf['build_mode'],
+ );
+
}
/**
@@ -201,7 +232,7 @@ function ctools_node_content_type_edit_form_validate(&$form, &$form_state) {
* Validate the node selection.
*/
function ctools_node_content_type_edit_form_submit(&$form, &$form_state) {
- foreach (array('nid', 'teaser', 'links', 'leave_node_title', 'link_node_title', 'identifier') as $key) {
+ foreach (array('nid', 'links', 'leave_node_title', 'link_node_title', 'identifier', 'build_mode') as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
diff --git a/plugins/content_types/node_context/node_content.inc b/plugins/content_types/node_context/node_content.inc
index ec12f67..3881fa1 100644
--- a/plugins/content_types/node_context/node_content.inc
+++ b/plugins/content_types/node_context/node_content.inc
@@ -18,10 +18,10 @@ $plugin = array(
'no_extras' => TRUE,
'override_title' => FALSE,
'override_title_text' => '',
- 'teaser' => TRUE,
'identifier' => '',
'link' => TRUE,
'leave_node_title' => FALSE,
+ 'build_mode' => 'teaser',
),
);
@@ -74,37 +74,46 @@ function ctools_node_content_content_type_render($subtype, $conf, $panel_args, $
}
function ctools_node_content_render_node($node, $conf) {
+
+ // Handle existing configurations with the deprecated 'teaser' option.
+ if (isset($conf['teaser'])) {
+ $conf['build_mode'] = $conf['teaser'] ? 'teaser' : 'full';
+ }
+
// The build mode identifies the target for which the node is built.
if (!isset($node->build_mode)) {
- $node->build_mode = NODE_BUILD_NORMAL;
+ $node->build_mode = ($conf['build_mode'] == 'teaser' || $conf['build_mode'] == 'full') ? NODE_BUILD_NORMAL : $conf['build_mode'];
}
+ // Determine the $teaser variable.
+ $teaser = $conf['build_mode'] == 'teaser';
+
// Remove the delimiter (if any) that separates the teaser from the body.
$node->body = str_replace('<!--break-->', '', $node->body);
// The 'view' hook can be implemented to overwrite the default function
// to display nodes.
if (node_hook($node, 'view')) {
- $node = node_invoke($node, 'view', $conf['teaser'], $conf['page']);
+ $node = node_invoke($node, 'view', $teaser, $conf['page']);
}
else {
- $node = node_prepare($node, $conf['teaser']);
+ $node = node_prepare($node, $teaser);
}
if (empty($conf['no_extras'])) {
// Allow modules to make their own additions to the node.
- node_invoke_nodeapi($node, 'view', $conf['teaser'], $conf['page']);
+ node_invoke_nodeapi($node, 'view', $teaser, $conf['page']);
}
if ($conf['links']) {
- $node->links = module_invoke_all('link', 'node', $node, $conf['teaser']);
+ $node->links = module_invoke_all('link', 'node', $node, $teaser);
drupal_alter('link', $node->links, $node);
}
// Set the proper node part, then unset unused $node part so that a bad
// theme can not open a security hole.
$content = drupal_render($node->content);
- if ($conf['teaser']) {
+ if ($teaser) {
$node->teaser = $content;
unset($node->body);
}
@@ -114,9 +123,9 @@ function ctools_node_content_render_node($node, $conf) {
}
// Allow modules to modify the fully-built node.
- node_invoke_nodeapi($node, 'alter', $conf['teaser'], $conf['page']);
+ node_invoke_nodeapi($node, 'alter', $teaser, $conf['page']);
- return theme('node', $node, $conf['teaser'], $conf['page']);
+ return theme('node', $node, $teaser, $conf['page']);
}
/**
@@ -138,11 +147,6 @@ function ctools_node_content_content_type_edit_form(&$form, &$form_state) {
'#default_value' => $conf['link'],
'#description' => t('Check here to make the title link to the node.'),
);
- $form['teaser'] = array(
- '#title' => t('Show only node teaser'),
- '#type' => 'checkbox',
- '#default_value' => $conf['teaser'],
- );
$form['page'] = array(
'#type' => 'checkbox',
'#default_value' => $conf['page'],
@@ -169,6 +173,38 @@ function ctools_node_content_content_type_edit_form(&$form, &$form_state) {
'#description' => t('This identifier will be added as a template suggestion to display this node: node-panel-IDENTIFIER.tpl.php. Please see the Drupal theming guide for information about template suggestions.'),
);
+ // CCK holds the registry of available build modes, but can hardly
+ // push them as options for the build mode options, so we break the normal
+ // rule of not directly relying on non-core modules.
+ if ($modes = module_invoke('content', 'build_modes')) {
+ $build_mode_options = array();
+ foreach ($modes as $key => $value) {
+ if (isset($value['views style']) && $value['views style']) {
+ $build_mode_options[$key] = $value['title'];
+ }
+ }
+ }
+ else {
+ $build_mode_options = array(
+ 'teaser' => t('Teaser'),
+ 'full' => t('Full node')
+ );
+ }
+
+ // Handle existing configurations with the deprecated 'teaser' option.
+ // Also remove the teaser key from the form_state.
+ if (isset($conf['teaser']) || !isset($conf['build_mode'])) {
+ unset($form_state['conf']['teaser']);
+ $conf['build_mode'] = $conf['teaser'] ? 'teaser' : 'full';
+ }
+ $form['build_mode'] = array(
+ '#title' => t('Build mode'),
+ '#type' => 'select',
+ '#description' => t('Select a build mode for this node.'),
+ '#options' => $build_mode_options,
+ '#default_value' => $conf['build_mode'],
+ );
+
return $form;
}