No results behavior

The No Results Behavior field provides the ability to display something when views would not otherwise return a result. You have the same options as header and footer, and this might be a good place to insert another view like a “Popular items” view so that the visitor isn’t left looking at a blank screen. We’ll just add some text for our example, but to see what the view looks like without a No Results Behavior, I’m going to unpublish chelsea’s Product #7.

With that done, we can switch back to Safari, and refresh. Now, Chelsea see’s an empty view because there are no published products that she created.

Let’s head back and add a text field to the No Results Behavior.

  • Click "Add"
  • [x] Global: Text area
  • (Apply(all displays))
    • There are no products that match this criteria.
  • (Apply(all displays))
  • (Save) (Save the view)

Now, when we switch back to Safari, and refresh, Chelsea is given an explanation about why the view is empty.

(I’ll go ahead and re-publish Product #7)

Expose the form in a block

The Exposed Form option provides the ability to separate view controls, such as our exposed filter from the view itself. Let's take a look at how we can move the exposed filter on the shop page into a block that we can position anywhere on the page, just like we would with any other block.

  • Click the "Page" display
  • Exposed form in block
    • Click "No"
      • Exposed form in block: [x] Yes (This will allow the exposed filter to appear in a block instead of displaying the exposed filter in the content area of the view.)
  • (Apply)
  • Exposed form style
    • Click "Basic"
    • [x] Basic (Here we have two options, basic and input required. If we choose input required, views will require the users to select an option from the filter before displaying the results while basic displays the results without requiring the user to select a filter option first.)
  • (Apply(all displays))
  • (Save) (Save the view)

Now, if we go to the Shop page and refresh, we’ll see that the filter criteria is gone.

Position the exposed filter block

Let’s display the exposed filter block in the sidebar.

  • Go to "Structure => Blocks" (admin/structure/block)
  • Scroll down to Disabled
    • Block: Exposed form: shop-page
    • Region: Choose "Sidebar first"
  • (Save blocks)

Now when we refresh the Shop page, we'll see that we have the Filter by Availability in the sidebar. Right now, this exposed filter is being displayed on every page but it is only used for the Shop view, so the next step is to configure this block to only appear on that page.

  • Mouse over the exposed filter block
  • Click the dropdown gear
  • Choose "Configure block"
    • Pages
      • Show block on specific pages: [x] Only the listed pages
        • shop (Enter the path of the view display excluding the "/" sign)
  • (Save block)

Save the block and return to home page. We'll see that the exposed filter is not displayed on this page anymore and when we go to the shop page we do see the exposed filter.