For some context, I’ve got an article content type with a custom ‘card’ viewmode configured to display teaser-esque article summaries throughout the site. Mostly these ‘cards’ are used on the search page to show results, however we’ve got different view blocks setup to show things like ‘featured’ articles and ‘latest’ articles – some of which are embedded onto the homepage.
The search results require different fields to be hidden/visible, whereas everywhere else on the site these cards are to show the same fields. Im using different twig files to distinguish the search results from the rest. For example, within search results the node--view--search-articles.html.twig
template is being used, and the node--article--card.html.twig
file is being used everywhere else.
The main issue is that when I run a search, then navigate to the homepage for some reason the node--view--search-articles.html.twig
file is being called, even though we’re not currently on the search page. BUT, this is also only the case for certain results within the same view block, not all of them. For example, within the same view block one of the view result would use the correct template, but the one right next to it would be using the search result template.
How is it possible that on the homepage we have instances of different suggestions being called for results of the same view? Im convinced this is cache related, because clearing cache fixes the issue, but obviously thats not a solution.
I can fix this by using other methods to hide the fields, such as css, but I’d like to understand whats happening here first or what would be the best solution.