node body handled incorrectly
profix898 - June 4, 2007 - 19:16
| Project: | Views |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Views outputs the $node->body field instead of $node->content['body'] and it doesnt call hook_nodeapi('alter'). This only happens for list_view and table_view, because views replaces node_view() with its own function (views_handler_field_body()) in this case.
The patch add the missing pieces and is a simple copy-and-paste from node.module to views_node.inc.
| Attachment | Size |
|---|---|
| views_node_output.patch | 985 bytes |

#1
Applied to -dev. Thanks!
#2
#3
This patch breaks one of my views for some odd reason. I have two views “etusivun_avaus” (avaus) and “etusivun_kolumni” (kolumni):
$view = new stdClass();$view->name = 'etusivun_avaus';
$view->description = 'Etusivun avauskirjoitus (blogimerkintä)';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '<h2 class="fp_extratitle"><a href="/vihreablogi" title="Vihreä blogi"><span class="otskuva" style="background-image: url(\'/sites/all/themes/vihreat_2.1/etusivukuvat/vihreablogi.gif\');"></span>Vihreä blogi</a></h2>';
$view->page_header_format = '3';
$view->page_footer = '';
$view->page_footer_format = '3';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'list';
$view->url = 'etusivun-avaus';
$view->use_pager = FALSE;
$view->nodes_per_page = '1';
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
),
array (
'tablename' => 'term_node_11',
'field' => 'name',
'label' => '',
'options' => 'link',
),
array (
'tablename' => 'users',
'field' => 'name',
'label' => '',
),
array (
'tablename' => 'node',
'field' => 'created',
'label' => '',
'handler' => 'views_handler_field_date_custom',
'options' => 'j.n.Y',
),
array (
'tablename' => 'node',
'field' => 'body',
'label' => '',
'handler' => 'views_handler_field_teaser',
),
array (
'tablename' => 'node',
'field' => 'link',
'label' => '',
'options' => 'lue lisää »',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
array (
'tablename' => 'term_node_11',
'field' => 'tid',
'operator' => 'AND',
'options' => '',
'value' => array (
0 => '249',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, term_node_11, users);
$views[$view->name] = $view;
$view = new stdClass();$view->name = 'etusivun_kolumni';
$view->description = 'Etusivun verkkokolumni';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '<h2 class="fp_extratitle"><a href="/taxonomy/term/106" title="Vihreitä ajatuksia"><span class="otskuva" style="background-image: url(\'/sites/all/themes/vihreat_2.1/etusivukuvat/vihreita_ajatuksia.gif\');"></span>Vihreitä ajatuksia</a></h2>';
$view->page_header_format = '3';
$view->page_footer = '<div class="links">
<a href="/fi/taxonomy/term/106" title="Lue aiemmat kirjoitukset" class="read-more">Lue aiemmat kirjoitukset »</a>
</div>';
$view->page_footer_format = '3';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'list';
$view->url = 'etusivun-kolumni';
$view->use_pager = FALSE;
$view->nodes_per_page = '1';
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
),
array (
'tablename' => 'users',
'field' => 'name',
'label' => '',
),
array (
'tablename' => 'node',
'field' => 'body',
'label' => '',
'handler' => 'views_handler_field_teaser',
),
array (
'tablename' => 'node',
'field' => 'link',
'label' => '',
'options' => 'lue lisää »',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
array (
'tablename' => 'term_node_4',
'field' => 'tid',
'operator' => 'AND',
'options' => '',
'value' => array (
0 => '106',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, users, term_node_4);
$views[$view->name] = $view;
Of these two, “kolumni” always works but “avaus” only works if I reverse profix898's patch. Otherwise it's teaser is not shown at all, although it should be.
The only practical difference with these two views is their “taxonomy: terms of” filter. “Avaus” belongs to term of vocabulary, which is reserved for our blog posts, and “kolumni” belongs to term of vocabulary that is reserved for stories (nodes shown in “avaus” are thus naturally blog posts and nodes shown in “kolumni” are stories).
Something isn't right here. But what?
#4
Since this patch is already in and released, changing this to 'patch (code needs work)' is confusing. Instead, file a new issue and reference this. Thanks.
#5
Was a new issue ever created for this? I'm experiencing this bug too now. Seems to affect only blog posts.