Skip to content

Instantly share code, notes, and snippets.

@Seorusus
Created December 14, 2022 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seorusus/86995fc93eab2980343cfedccfee20ca to your computer and use it in GitHub Desktop.
Save Seorusus/86995fc93eab2980343cfedccfee20ca to your computer and use it in GitHub Desktop.
Переменные для таблицы. Thead, rows
/**
* Implements hook_preprocess_views_view_table().
*/
function basf_views_preprocess_views_view_table(&$variables): void {
/** @var \Drupal\views\ViewExecutable $view */
$view = $variables['view'];
$trows = [];
$thead = [];
if ($view->id() === 'listing_' . $view->current_display) {
switch ($view->current_display) {
case 'msds':
case 'tds':
foreach ($variables["header"] as $column) {
$thead[] = $column["content"];
}
$variables['thead'] = $thead;
foreach ($variables['rows'] as $index => $row) {
foreach ($row['columns'] as $column) {
$trows[$index][] = $column['content'][0]['field_output'];
}
}
$variables['trows'] = $trows;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment