I'm trying to use a view inside a loop but it's not working, I'm using "views_get_view($name)" but "clone_view()" / "copy()" is not working, I can't create another reference.
I have a view with a contextual filter and by settings different arguments on each loop with "set_arguments" the result should be different. I get the result for the first loop but all the others are empty.
I'm trying to use something like this:
for($i=2; $i<=4; $i++){
$view = views_get_view('view_name');
$view->set_display($i);
$view->set_arguments(array($i));
$view->execute();
dpm($view->result);
}
and the result is:
... (Array, 4 elements)
... (Array, 0 elements)
... (Array, 0 elements)
The first result is working great (4 elements inside the array) but the others are empty.
I know the above code is not correct as this is not the way to handle objects but at least you will know what I want, a different result for each set of arguments, arguments which are connected to a contextual filter inside view.
Can someone help me with a method to use the view inside a loop ? I only managed to generate the result once no mather what.
Thanks.