Jump to:
| Project: | Chaos tool suite (ctools) |
| Version: | 7.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
We have a Biblio node type with several additional fields attached to it (eg, File Download, Image, Related Node)
Panels is used to manage the node's layout, and Drupal regions are extinguished. We are using an Adaptive 3x4 layout.
In a layout region I have placed the node_content element. I don't want to show the additonal fields--only the core Biblio fields.
In the configuration, I have checked the No Extras option:
[ X ] No extras
Check here to disable additions that modules might make to the node, such as file attachments and CCK fields; this should just display the basic teaser or body.We select Build mode=Full node
When the page renders, we see the 3 custom fields (image, file download, and related node reference) displayed in the Full node region...this is not expected, based on a literal reading fo the 'No Extras' option.
I posted this issue to the Biblio queue, and the maintainer was kind enough to come back with response:
I took a quick look in the function that does the rendering (ctools_node_content_render_node()) in the ctools node_content.inc file, and the bottom line is that ... ('No Extras' does not function as advertised) ...
You can see below, where it says "// Build fields content." that field_attach_view() is being called which renders the fields you are seeing.
Seems to me that that line should also be wrapped in a conditional like this...
if (empty($conf['no_extras'])) {
$node->content += field_attach_view('node', $node, $conf['build_mode']);
}<?php
function ctools_node_content_render_node($node, $conf) {
if (empty($node->content)) {
// Copied from node_build_content() so we can fiddle with it as we render.
$node->content = array();
// 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['build_mode']);
}
// Build fields content.
// In case of a multiple view, node_view_multiple() already ran the
// 'prepare_view' step. An internal flag prevents the operation from running
// twice.
field_attach_prepare_view('node', array($node->nid => $node), $conf['build_mode']);
entity_prepare_view('node', array($node->nid => $node));
$node->content += field_attach_view('node', $node, $conf['build_mode']);
// Always display a read more link on teasers because we have no way
// to know when a teaser view is different than a full view.
$links = array();
if ($conf['build_mode'] == 'teaser') {
$links['node-readmore'] = array(
'title' => t('Read more'),
'href' => 'node/' . $node->nid,
'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))
);
}
$node->content['links'] = array(
'#theme' => 'links__node',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
if (empty($conf['no_extras'])) {
// Allow modules to make their own additions to the node.
$langcode = $GLOBALS['language_content']->language;
module_invoke_all('node_view', $node, $conf['build_mode'], $langcode);
module_invoke_all('entity_view', $node, 'node', $conf['build_mode'], $langcode);
}
}
// Set the proper node part, then unset unused $node part so that a bad
// theme can not open a security hole.
$content = $node->content;
$content += array(
'#theme' => 'node',
'#node' => $node,
'#view_mode' => $conf['build_mode'],
'#language' => NULL,
);
// Add contextual links for this node, except when the node is already being
// displayed on its own page. Modules may alter this behavior (for example,
// to restrict contextual links to certain view modes) by implementing
// hook_node_view_alter().
if (!empty($node->nid) && !($conf['build_mode'] == 'full' && node_is_page($node))) {
$content['#contextual_links']['node'] = array('node', array($node->nid));
}
// Allow modules to modify the structured node.
$type = 'node';
drupal_alter(array('node_view', 'entity_view'), $content, $type);
// Kill the links if not requested.
if (!$conf['links']) {
$content['links']['#access'] = FALSE;
}
return $content;
}
?>Could you please clarify what should be happening here?
Thanks indeed
Comments
#1
Unfortunately, in general if you skip field_attach_view(), you won't actually render anything at all. With the switch to field API, with the 'body' now being a field, that is primarily what you used to get with 'no extras'. In Drupal 7, that flag...really doesn't end up having a lot of meaning, I'm afraid. :(
#2
Ok, thanks for the insight Merlin.
Perhaps it would be better to adjust the UI so our expectations are lowered?
Is that something I can help with?
Can we close this issue, works as designed?
Cheers.
#3
I agree, attempting to adjust the UI is probably a good idea. I am not quite sure what to do, though. Obviously the reference to CCK is outdated.