Solved

programmatic view: where is the pager?

Posted on 2010-08-30
4
1,323 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't login to Drupal site after domain change 6 982
Redirect new users to custom pages after registration 2 1,417
Drupal Installation Problem 5 98
any good free penetration tools? 4 409
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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