Last active
October 3, 2016 15:09
-
-
Save madalinignisca/314418f5f4518c64ed51569a61f48a49 to your computer and use it in GitHub Desktop.
Load correct number of items when using Views Load More
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_query_alter() | |
*/ | |
function views_pager_mod_views_pre_execute(&$view) { | |
// some data to be used | |
$query_params = drupal_get_query_parameters(); | |
// Load the amount of items the user was looking at previous on Listings | |
if ($view->name == 'listing' and isset($query_params['historypage'])) { | |
$query = $view->build_info['query']; | |
$limit = $view->query->limit + ($query_params['historypage'] * $view->query->limit); | |
$query->range(0, $limit); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment