Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
6.x-2.7
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2009 at 11:17 UTC
Updated:
9 Nov 2009 at 20:16 UTC
I have a page view that display one node. Then there is an attached view which displays other nodes. Now I want to modify the query of the attached view to not display the node of the first view. The problem is that this:
function recticel_views_pre_execute($view) {
if ($view->name == 'references' && $view->current_display == 'attachment_1') {
// var_dump($view->current_display);
$aview = views_get_view('references');
$aview->execute('page_1');
var_dump($aview->result); exit;
}
}
generates infinite recursion. If I manually set the current_display it won't recurse but I won't get a result either. This code works fine when called from somewhere else than a view hook.
Is there any way to render a view display from the same view in a views hook?
Comments
Comment #1
jax commentedIf I set 'accept attachments' to false it works:
In other hooks I don't get any results back. Is this the way this should be done?
Comment #2
jax commentedYou need to pass the arguments back if you're using that:
Comment #3
merlinofchaos commentedMy assumption here is that you have attachment_1 set to attach to page_1 which of course will cause infinite recursion, as you see attachment_1 running, try to run page_1 which then attaches attachment_1 and then you see attachment_1 running, ad infinitum.
So, uh, other than saying "Don't do that" I don't really have any good ideas.