Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-beta2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 May 2008 at 22:01 UTC
Updated:
1 Oct 2011 at 04:00 UTC
Is there a way to pass the number of items to display per page as argument to an embed view by code?
I used to do that with Views 1 in this way:
$view = views_get_view('hpTab1NonFeatured');
print views_build_view('embed', $view, null, false, 2);
where 2 were the number of items to display.
Now i have this code in Views 2:
$args = array();
$v = views_get_view('moreNews');
echo $v->execute_display('default', $args);
I don't know where i can pass that argument. Is there a way?
Thanks in advance!
Matias.
Comments
Comment #1
merlinofchaos commentedYou can do this:
Note that I generally prefer adding additional displays if you want to change options, since you can easily select an alternate display. Though I guess I don't have any extra 'do nothing' displays so you'd probably have to add block displays. And with those you don't actually want to use $v->execute_display(), you want to use $v->preview() (because execute_display will return a block object suitable for hook_block()).
Comment #2
merlinofchaos commentedComment #3
mburak commentedIt's showing nothing with that code that you suggested. Are you or me missing something? The view result seems to be empty.
Comment #4
mburak commentedNevermind, i missed the 'echo' before the $v->execute_display();
Thanks!!
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #6
Dimm commentedComment #7
alienzed commentedNone of those suggestions work for me... has this changed again?
All I want to do is load and render a view from within a drupal 'Page' and set the items per page manually.
my ultimate goal is to allow the user to select his/her prefered items per page count, hold that data in a session variable and load it into each view for setting the items per page...
but I can't figure out how to programmatically set the items_per_page...
Comment #8
haleagar commentedsee http://drupal.org/node/404714
$view->set_items_per_page($number);
Comment #9
giorgio79 commentedIs there a way to use this as a URL argument?