There is a page on a site I'm building that is going to have a View embedded four times, each time with a different argument. Basically, I'm showing the latest post for four different categories that the posts are organized into.
I want each embedded View to show one post at a time and use AJAX pagers to allow users to page to the next-oldest post in a particular category right there on that page. Of course, the following code doesn't work because pager_element is set to 0 for each of them.
print views_embed_view('principles', 'embed', 'access');
print views_embed_view('principles', 'embed', 'choice');
print views_embed_view('principles', 'embed', 'openness');
print views_embed_view('principles', 'embed', 'innovation'); If I manage to set pager_element for these from 0-3, would that make all the pagers work, even though they are all on one page?
I've been trying to do this, but I don't really know my way around setting options for a View and then rendering it. With the following code, the View renders all of the results without a pager, rather than the one at a time with a pager. Any guidance on how to set pager_element so that each of these embedded views along with their AJAX pagers work would be greatly appreciated!
$innovation = views_get_view('principles');
$innovation->set_display('default');
$innovation->set_arguments(array('innovation'));
$innovation->display['default']->display_options['pager_element'] = 5;
$innovation = $innovation->render();
print $innovation;
Thanks.
Comments
Comment #1
akahn commentedAlright, so I've found that I can't use 'embed' as the display id, it has to be 'page_2'. That makes some stuff work better. But I'm still having an issue where when I print the view using
$innovation->render(), for example, all of the results get spit out, rather than just 1, like it is set to, with a pager. Why is this? Also, how comeprint $innovation->preview()doesn't output anything? I'm sort of followingpanels_views.moduleas a model for how to set options and print the view, but not having much luck.Comment #2
merlinofchaos commentedThe options for the pager get copied from the display to the view during pre_execute(). If you are not using preview() or execute_display() you must be sure to run pre_execute().
Comment #3
domesticat commentedClosed while closing all Views support requests with no activity for 6 months. If you still need help, you may re-open this issue at any time.