Created
December 14, 2022 17:02
-
-
Save Seorusus/86995fc93eab2980343cfedccfee20ca to your computer and use it in GitHub Desktop.
Переменные для таблицы. Thead, rows
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_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