Hello to all-

I have some strange but complex(for me, anyways) problems with my Drupal site. I have two block views, one called 'recent posts' and the other called 'most popular' in my right sidebar. The are both setup as table views with a little formatting via the template.php. Both views display the fields user: picture, node: title, node: body, and node: author: name.

My problems are following. With the views field, 'node: body' enabled, my login page does not display the tabs "login, register, request new password." Also, my forum breadcrumbs do not update to the correct forum topic when viewing anonymously. They seem to work fine when logged in. Also, when going to the user/register page, the title of the page is one of my forum topics, not 'user account.' My user/login page was doing the same thing, but some code was added to change that title. When I disable the 'node: body' field for both views, all of these problems disappear.

So, has anyone come across this problem before or have advice on a possible solution, other than removing the 'node: body' field from the view ;) I appreciate your taking the time to read this. Thanks!!

CommentFileSizeAuthor
#8 views-176360-8.patch1.06 KBrstaylor

Comments

Jussi_S’s picture

Have you found a solution for this? I too am experiencing something like this: second level tabs are missing if node:body is enabled in any visible views. For example, if I have a user profile expanding to a few tabs, they are not shown. Removing node:body from all visible views fixes the problem.

amitaibu’s picture

Component: Miscellaneous » Views Data

I'm not sure about this specific issue, but note the node:body in the views module shows the whole content of the node (not only what you refer to as 'body'). In order to show only the, let's call it body_field, you can use the CCK to create a new text area field.

talktozee’s picture

I have the same problem. I'll try to use the CCK fix, but I'd rather modify the code to make this work.

talktozee’s picture

CCK wasn't as elegant as I would have liked. So I tracked down exactly what was happening during the "Node:Body" field's generation. I'm no farther ahead, but this might help someone track down the problem:

A block view that includes "Node:Body" generates this code for the inclusion of the body as part of "$view->field" array.

array ( 'tablename' => 'node', 'field' => 'body', 'label' => '', 'handler' => 'views_handler_field_teaser', )

So, when "Node:Body" is included in a field, the code either calls "views_handler_field_teaser" or "views_handler_field_body", depending on what the "Node:Body" field is set to.

These two functions are found in /modules/views/modules/views_node.inc

/*
* Format a field as the Body of a node.
*/
function views_handler_field_body($fieldinfo, $fielddata, $value, $data) {
$node = node_load($data->nid);

if ($fielddata['handler'] == 'views_handler_field_body') {
$teaser = FALSE;
}
else {
$teaser = TRUE;
}

$node->body = str_replace('

', '', $node->body);

// The 'view' hook can be implemented to overwrite the default function
// to display nodes.
if (node_hook($node, 'view')) {
node_invoke($node, 'view', $teaser, TRUE);
}
else {
$node = node_prepare($node, $teaser);
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', $teaser, TRUE);

return $teaser ? $node->teaser : $node->body;
}

/*
* Format a field as the Teaser of a node.
*/
function views_handler_field_teaser($fieldinfo, $fielddata, $value, $data) {
return views_handler_field_body($fieldinfo, $fielddata, $value, $data);
}

gemini’s picture

I have similar problem with views and breadcrumbs when using Node: body. Looks like the breadcrumbs are basically overwritten by node. Had to switch to Teaser List and re-theme my teasers.

ashtonium’s picture

Version: 5.x-1.6 » 5.x-1.x-dev

Subscribing with the same problem. Changed issue version to 5.x-1.x-dev

sun’s picture

Title: Problem with the views 'node: body' field when enabled » Malformed menu/breadcrumb when view contains Node: Body field
Version: 5.x-1.x-dev » 5.x-1.6
Component: Views Data » node data

FYI: #254403: node:body field inserts entire node in view is a separate issue and already contains a patch.

Changing title accordingly. Resetting version.

rstaylor’s picture

Status: Active » Needs review
StatusFileSize
new1.06 KB

Tested on Drupal version 5.10, Views version 5.x-1.6

Symptoms

* Local task tabs disappear on some pages (not on pages that are default local tasks)
* Breadcrumbs are sometimes wrong
* Page title is wrong on some pages

The bug occurs when you have a view in which one of the fields is Node:Body displayed on the page (for instance, a block list view including teasers). It does not always occur, it depends upon the modules involved, the content type of the nodes in the view, and the page that you're on.

Steps to Replicate

1 Install a fresh copy of Drupal to test, and the Views module.
2 Create a few blog post nodes
3 Create a block view, type: list, fields: node:title as link, node:body as teaser.
4 Go to admin/build/block/add; verify that the page title is correct and local task tabs are showing.
4 Activate the block at admin/build/block.
5 Go to admin/build/block/add. Verify that the page title is now wrong and local task tabs are missing.

Cause

In views_node.inc, views_handler_field_body() calls
node_invoke($node, 'view', $teaser, TRUE);
and
node_invoke_nodeapi($node, 'view', $teaser, TRUE);

This in turn calls hook_view in whatever module corresponds to the content type. It always passes TRUE for $page. Often, a module's hook_view will check $page (but not teaser) and do things such as menu_set_location(), which changes the menu (destroying local tasks), breadcrumbs, and possibly title on some pages.

Suggested Solution:
Change the calls to node_invoke() and node_invoke_nodeapi() to always pass FALSE instead of TRUE for $page.

In a page view, the page menu location/title/breadcrumbs should be set by the view itself, not by one of the nodes in the view. And of course, nodes in a block view should not affect the menu location. So I think $page should always be FALSE for nodes in a view.

sun’s picture

I agree with this patch and the reasoning behind it. However, this patch requires a bunch of confirmations from other users who have implemented a bunch of views in their site already.

bago’s picture

Priority: Normal » Critical

I lost 5 hours investigating on a TinyMCE issue that resulted in no issue in TinyMCE but THIS issue in views.
Many modules checks the $page argument of the hook_view and this break everything.

Also my task menu, for the node shown in the page while a view shown other nodes in list-view in a block of the same page, was disappearing because of this.

I think this is very critical.

Also, http://drupal.org/node/226172, should be fixed in the mean time.

gotheric’s picture

Priority: Critical » Normal

I agree with this patch.
This bug create problems with several modules and functions when using a list view (and it took me a lot to find it!).

seanr’s picture

Priority: Critical » Normal

This patch worked flawlessly for me on a site with a ton of views. That bug was a b****, glad someone figured it out.

rstaylor’s picture

Status: Needs review » Reviewed & tested by the community

It's been half a year with no objections. This bug causes critical errors, is easy to replicate/test, and the cause is obvious once you look at it. Can the patch be committed now?

seanr’s picture

Priority: Normal » Critical

Yes, PLEASE, since it just came back and I'd completely forgotten about this. What an obnoxious stupid bug. I just wasted an hour pulling my hair out for the second time because of this.

dawehner’s picture

I don't see this as a critical bug.

A WSOD for example is a critical bug.

esmerel’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

At this time, only security fixes will be made to the 5.x version of Views.