Nested view reference fields

chris_car - November 10, 2009 - 03:30
Project:View Reference
Version:6.x-2.23
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello,

I have a content type A (part of a book -> parent node) which uses a view reference field to output a view which takes an argument (nid) to embed a listing of children of this book node. Each child is from content type B which uses itself a view reference field to output its children.

The problem is that I get an internal server error when viewing the parent node of the book, if the content types of the children use view reference to embed a view as well. It works fine if I disable the view reference in the children content types.

Is there a solution to that or did I do something wrong? Is a nested configuration like that working at all?

I hope you understand my explanation.

Any help would be very much appreciated!

Chris

#1

danielb - November 10, 2009 - 05:03
Category:bug report» support request
Status:active» postponed (maintainer needs more info)

I need to know what the error is.

#2

chris_car - November 10, 2009 - 15:29

Scenario: The parent node has a view children field (view reference) switched on and it works (because the listed child has it switched off). If I switch it on for the child as well and I navigate to the child page, it works fine. But if I navigate to the parent node, I get an internal server error and the web server log just says: [Tue Nov 10 16:12:23 2009] [error] [client x.x.x.x] Premature end of script headers: index.php, referer: http://mysite.com/node/44/edit (44 is the nid of the parent node).

Thanks!

#3

danielb - November 11, 2009 - 10:53
Status:postponed (maintainer needs more info)» active

I wonder if the views handler for books loads the parent node which renders the view again which creates an endless loop, or something along those lines.

#4

chris_car - November 11, 2009 - 17:12

I was thinking the same. Though I did not look at your code yet or debugged it.

I was also thinking to just use views_embed_view() in my template files for the content types instead, and to call the view directly.

#5

chris_car - November 11, 2009 - 19:26

I just realized that if I embed the view directly, it does not change anything concerning the problem. So what I did is that I embedded the view into my template files but made sure that the view is not called when the node is part of a view and already embedded. I compare the node ids of the current url and of the node variable in the template.

<?php
print $content
   
/* if this node is embedded via a view, don't call views_embed_view again */
   
if (arg(1) == $node->nid) {
      print
views_embed_view('book_children', 1, $node->nid);
    }
?>

#6

danielb - November 12, 2009 - 03:05

Did this solve the problem? I was going to suggest excluding the viewreference field under cck's 'display fields' tab because this probably causes the view reference field to internally load and process the views whenever node_load() is called. In the template it will be fine.

#7

chris_car - November 12, 2009 - 15:18

Yes, it solved the problem. If I got time I will try to exclude the field in the display tab... I did not think of that at all, but it could work as well.

Nevertheless, thank you!

#8

danielb - November 14, 2009 - 06:23
Status:active» fixed

#9

System Message - November 28, 2009 - 06:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.