Created
December 14, 2022 17:00
-
-
Save Seorusus/94023e2bfd36eebde67cebbf7c81bc98 to your computer and use it in GitHub Desktop.
Счетчик количества айтемов в таблице
This file contains 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
/** | |
* Implements hook_preprocess_views_view(). | |
*/ | |
function basf_views_preprocess_views_view(&$variables): void { | |
global $language; | |
$view = $variables['view']; | |
if ($view->id() === 'search' && $view->current_display === 'search_page') { | |
$query = $view->getExposedInput(); | |
if (isset($query['query']) && $query['query']) { | |
$variables['search_input'] = t( | |
'Search results for “@query”', | |
['@query' => $query['query']] | |
); | |
} | |
else { | |
$variables['search_input'] = t('Search results'); | |
} | |
$variables['totalRows'] = t('@totalRows hits', ['@totalRows' => $view->total_rows]); | |
$variables['bottom_content'] = _basf_views_get_bottom_card_grid(); | |
} | |
if ($view->id() === 'listing_msds' && $view->current_display === 'msds') { | |
// TODO $country should be implemented. | |
$country = NULL; | |
$query = $view->query->query()->countQuery()->execute()->fetchAssoc(); | |
$count = reset($query); | |
// Gets count of views table items. | |
if (empty($country)) { | |
$variables['count'] = t( | |
'@count hits in @language', | |
[ | |
'@count' => $count, | |
'@language' => $language, | |
] | |
); | |
} | |
else { | |
$variables['count'] = t( | |
'@count hits for @country in @language', | |
[ | |
'@count' => $count, | |
'@country' => $country, | |
'@language' => $language, | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment