<div dir="ltr"><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:&#39;Lucida Grande&#39;,&#39;DejaVu Sans&#39;,&#39;Bitstream Vera Sans&#39;,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:&#39;Lucida Grande&#39;,&#39;DejaVu Sans&#39;,&#39;Bitstream Vera Sans&#39;,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 &quot;Display all items&quot; radio button, in &quot;Pager -&gt; Use Pager&quot; 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 -&gt; &quot;$view-&gt;set_items_per_page(1);&quot;<br>I have tried adding $view-&gt;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 &quot;type&quot; of pager.<br>If &quot;type&quot; is &quot;none&quot;, the pager is never called, which is the case, when I select the option as &quot;Display all items&quot; mentioned above.<br>If &quot;type&quot; is &quot;some&quot;, 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:&#39;Lucida Grande&#39;,&#39;DejaVu Sans&#39;,&#39;Bitstream Vera Sans&#39;,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 &quot;type&quot; property of pager form &quot;none&quot; to &quot;some&quot;, I can crack this.<br>Any help is appreciated.</p><p style="margin:0px 0px 1.385em;padding:0px;border:0px;font-family:&#39;Lucida Grande&#39;,&#39;DejaVu Sans&#39;,&#39;Bitstream Vera Sans&#39;,Verdana,Arial,sans-serif;font-stretch:inherit;line-height:17.9999942779541px;font-size:13px;vertical-align:baseline">Thanks.</p><div>Drupal.org Forum Link -&gt; <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>