0

I have a view that needs to embed child views, which I did using the twig_tweaks module to insert the child view as a field in my parent view, by using a custom text field:

{{ drupal_view('my_child_view', 'block_1', arguments.null, tid) }}

The first argument arguments.null is the group id, which the child views get from the URL

example.com/group/58/parent-view

It all works perfectly when i view the results for a given group id. However, when I then open the view for another group id, I get the results for the first queried group id. The results will only change after i delete the Drupal caches. Then I can display the view correctly for any group id, but afterwards, it will again never change the results.

My best guess is that the results of the embedded view are cached? Is there any way to disable this? I tried including {'#cache': {'max-age': 0}} into the custom text embedding the child view, but this did not help either.

0

Use the Views Field View module instead.

There are a lot of cases in views where you want to embed a list inside each row. One example could be, you have a list of groups, and for each groups you want to list the first and last name of all of their members.

Then in the Views UI add view embed as field.

1
  • unfortunately, embedding a view as field has performance/stability issues, thats why i wanted to do it via twig
    – stemiwe
    Sep 9 '20 at 7:17
-1

I found an easy solution: just disable the caching for the parent view itself in its advanced settings.

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.