I have two content types. For clearer question I will work with the content types event and location.
From my location content type I can reference to and event.
Then on the event page I show the location that is connected to this event. I do this by creating a Views Block. This views block is showing content of the type location with a contextual filter to only show content with the Content ID from url.
This works fine. But there are events that don't have a location. On these events page I have a button saying add location. I do this with the following Twig Tweak:
{% if drupal_view_result('view-name', 'location-block') is empty %}
<a href="/node/add/location">Add location</a>
{% else %}
{{ drupal_view('view-name', 'location-block') }}
{% endif %}
This also works. But when I am on a event page and click the add location button I can add the location. When I go back to the same event page I was before I still see the add location button. Because the page is cached.
Is there a way to empty the cache of this event page after saving the location that is refering to the event? Or is there a other way to deal with this?
I tried if the problem was in the views cache but it wasn't turning it off for the block or removing only the views cache didn't work.
Thanks in advance
<a href="/node/add/location?nid={{nid}}">Add location</a>
I couldn't find a way to do this with Views.[current-page:url:unaliased:args:value:1]
in a Views text area, see drupal.org/node/1360922