No results behavior in Views not working when referencing another field after cache clear

My Setup:

I am using Drupal 7.41 and Views / Views UI 3.11.

  1. I have a taxonomy named sermon series that includes a field called series image.
  2. I have a content type called sermons that has an image called sermon image and a term reference to the sermon series taxonomy.
  3. Lastly, I have a View called sermons that:
    • pulls in the most recent 1 node from the content type sermons
    • has a relationship to the taxonomy sermon series
    • has the first field in the fields list as the sermon series image (from taxonomy) and is set to “hide from display”. The replacement pattern token for this field is [field_sermon_image_2]
    • has the second field in the fields list as the sermon image (from content type) and is set to show in the display.
      • this field has a no results behavior set to the token [field_sermon_image_2]

Expected Behavior:

If the most recent node has an image associated with it, that image will show. If there is no image associated with the node, it will show the image associated with the taxonomy sermon series.

Actual Behavior

When I create a node with the sermon image filled out, everything works as expected and the view shows the sermon image associated with the Node shows.

When I create a node without a sermon image filled out, the view correctly shows the sermon series image associated with the taxonomy sermon series.

Here’s where it gets weird. If I create a node without a sermon image filled out, see the view correctly show the sermon series image from the taxonomy, then either clear cache or wait until cache expires, no image shows up at all. I know the fallback is working correctly as even the [field_sermon_image_2] has a no results behavior fallback to a generic image and that’s what always shows up.

Through some testing, I found that unpublishing the node, viewing the view, then re-publishing the node will bring the correct image back (at least until the next cache flush).

I’m not sure where to look for this odd behavior. It seems like I have everything setup correctly in my view as I can get the correct images to show up, I just can’t get them to show up consistently.

Any advice you can give would be appreciated. Thanks!

Sponsored by SupremePR
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

No results behavior in Views not working when referencing another field after cache clear

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.