<div dir="ltr"><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:'Lucida Grande','DejaVu Sans','Bitstream Vera Sans',Verdana,Arial,sans-serif;font-stretch:inherit;line-height:17.9999942779541px;font-size:13px;vertical-align:baseline">Hello Everyone,</p><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:'Lucida Grande','DejaVu Sans','Bitstream Vera Sans',Verdana,Arial,sans-serif;font-stretch:inherit;line-height:17.9999942779541px;font-size:13px;vertical-align:baseline">I am using Drupal 7.34 and Views 7.x-3.8<br>I have created a view, where I ask views to fetch all results, by selecting "Display all items" radio button, in "Pager -> Use Pager" section.<br>I now, alter the query using hook_views_query_alter, and If a condition is met, I add a condition, and if a condition is not met, I ask the view to fetch only 1 result.<br>The else case is causing issues for me.<br>My code in else case is this -> "$view->set_items_per_page(1);"<br>I have tried adding $view->init_pager(); as well, but no good.<br>I am not able to get views fetch only 1 result, if the custom condition in hook_views_query_alter is not met.<br>On Debugging, I saw that what views does is defines the "type" of pager.<br>If "type" is "none", the pager is never called, which is the case, when I select the option as "Display all items" mentioned above.<br>If "type" is "some", the pager starts working, as pager is set to some, and value items_per_page shows its effect.</p><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:'Lucida Grande','DejaVu Sans','Bitstream Vera Sans',Verdana,Arial,sans-serif;font-stretch:inherit;line-height:17.9999942779541px;font-size:13px;vertical-align:baseline">I believe, If I can find a way to change the "type" property of pager form "none" to "some", I can crack this.<br>Any help is appreciated.</p><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:'Lucida Grande','DejaVu Sans','Bitstream Vera Sans',Verdana,Arial,sans-serif;font-stretch:inherit;line-height:17.9999942779541px;font-size:13px;vertical-align:baseline">Thanks.</p><div>Drupal.org Forum Link -> <a href="https://www.drupal.org/node/2402617">https://www.drupal.org/node/2402617</a></div>-- <br><div class="gmail_signature">Regards,<br>Vaibhav Jain</div>
</div>