Solved

programmatic view: where is the pager?

Posted on 2010-08-30
4
1,319 Views
Last Modified: 2012-05-10
Hi. I have build a view that uses a pager. When I call the view (page path) the pager is shown as expected. But when rendering the view programmatically it is not:
  $view = views_get_view("interviews");
  $view->args = array("Interview");
  $view->execute('page');
  echo $view->render();

Open in new window


What am I doing wrong?
Thanx in advance
0
Comment
Question by:simonwidjaja
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Thomas4019
ID: 33558393
Don't programatically create the view that way. Use views_embed_view, http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view
0
 

Author Comment

by:simonwidjaja
ID: 33558842
I need the view object before rendering, because I have to modify the query before rendering. Is there a possible way to get the pager enabled with $view->render();?
0
 
LVL 17

Accepted Solution

by:
Thomas4019 earned 250 total points
ID: 33559999
You could use this to modfiy the query, http://www.nicklewis.org/hook-views-query-alter-how-programatically-alter-views-queries, and views_embed_view accepts arguments.

Or maybe add something like this,
$view->display['default']->handler->options['display_options']['use_pager'] = TRUE;
0
 

Expert Comment

by:ellyjonez
ID: 33563801
Try setting the number of items per page right there before you render:

$view->set_items_per_page(20);
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for those that are having major problems with users upload files such as pictures to their profile. The solution is simple and has to do with correcting the directory paths. With some experimenting and testing i got it fixed. Note…
RTL (right to left) web applications aiming for audiences speaking languages like Hebrew or Arabic, are generally more complicated than the same applications aiming for audiences speaking Latin based languages. The main difference lies of course …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question