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 ? – berramou May 29 at 19:23
  • I created My Vocabulary page. This page must be loaded with a contextual filter. This contextual filter takes IDs. – Asatur Vardanyan May 29 at 19:29

Use hook_views_pre_view

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.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.