I'm trying to pass same arguments to views. Here is my code:
$view = Views::getView('taxonomy_articles');
if (!empty($age)) {
$view->setDisplay('block_6');
$view->setArguments([$term->tid, $age_args]);
/*
* override term name with age param
*/
$termURL = Url::fromRoute('entity.taxonomy_term.canonical', array('taxonomy_term' => $term->tid, 'age' => $age));
$termName = \Drupal::l(t($term->name), $termURL);
}
else {
$view->setDisplay('block_1');
$view->setArguments([$term->tid]);
}
My else
part gets executed and array of term ids goes to block_1, my view block machine name.
What I want is similar like:
else {
$view->setDisplay(['block_1','block_7']);
$view->setArguments([$term->tid]);
}
Is this possible? Can we pass array to $view->setDisplay
???