function _views_navigation_build_query in Views navigation 7
Add the query parameters to append to the entity url.
3 calls to _views_navigation_build_query()
- views_navigation_handler_field_field::render_item in views/
views_navigation_handler_field_field.inc - Implements function render_item().
- _views_navigation_build_url in ./
views_navigation.inc - Used when the view handler needs an already built url.
- _views_navigation_render_entity_link in ./
views_navigation.inc - Based on EntityFieldHandlerHelper::render_entity_link().
File
- ./
views_navigation.inc, line 276 - Views navigation main include file.
Code
function _views_navigation_build_query($etid, $view, $query = []) {
if (isset($view->views_navigation_cid)) {
// Todo handle the case when the etid is in the result more than one time.
$etids = [];
$plugin = _views_navigation_get_query_plugin($view->query);
$entity_type = _views_navigation_get_entity_type($view->query);
$id_key = _views_navigation_get_id_key($entity_type);
foreach ($view->result as $result) {
switch ($plugin) {
case 'default':
$etids[] = $result->{$id_key};
break;
case 'search_api':
if (is_object($result->entity)) {
$etids[] = $result->entity->{$id_key};
}
else {
$etids[] = $result->entity;
}
break;
}
}
$index = array_search($etid, $etids);
// Index of first item on second page must be items_per_page, not 0.
$pager = $view->query->pager;
if ($pager
->use_pager()) {
$index += $pager
->get_items_per_page() * $pager
->get_current_page();
}
$query = array_merge($query, [
VIEWS_NAVIGATION_POSITION_PARAMETER => $index,
VIEWS_NAVIGATION_CACHE_ID_PARAMETER => $view->views_navigation_cid,
]);
}
// Allow modules to alter the query string.
drupal_alter('views_navigation_query_string', $query, $index, $view);
return $query;
}