I am using Drupal 8. Added new view My Vocabulary and created a contextual filter with paragraph ID. Now I need to render the view with passed parameters to contextual filter. What hook to use to solve my problem. Thanks.
-
can you explain what do you want to achieve exactly ? where do you want to render this view and so on ?– berramouCommented May 29, 2020 at 19:23
-
I created My Vocabulary page. This page must be loaded with a contextual filter. This contextual filter takes IDs.– Asatur VardanyanCommented May 29, 2020 at 19:29
Add a comment
|
1 Answer
function mymodule_views_pre_view(\Drupal\views\ViewExecutable $view, $display_id, array &$args) {
// Modify contextual filters for view_name.
$paragraph_id = 22;
if ($view->id() == 'view_name') {
$args = [$paragraph_id]; // args must be an array.
}
}