This module all seems to working fine except for the scenario when there are no possible results i.e. ZERO matching taxonomy terms.

In this situation I think the empty block itself should not show at all.

Comments

saltednut’s picture

Category: bug » feature

This is not a bug as we've intended to build this way.

I understand this is the behavior one would see from a Views block, so I'm changing it to a 'Feature Request'.

I've talked with indytechcook about this issue with Beans (in general) and his feedback was this should be handled through theme templates.
-- See: http://drupal.org/node/1380640

I think we could handle this in the class as well but I haven't dived into the issue.

The best course of action might be to include a checkbox on the form that says 'do not display block if no results' or something along those lines.

There are cases where people want to see the block even without any results.

valderama’s picture

I have solved this like this for a custom bean type. Happy on any suggestions and of course if we could add "standard" way for all beans.

/**
 * Implements hook_block_view_alter
 */
function mymodule_block_view_alter(&$data, $block) {
  if ($block->module == 'bean') {
    
    if (isset($data['content']['#norender'])) {
      // react on the self-invented no-render property and unset stuff to avoid
      // rendering of the whole block
      $data['content'] = $data['subject'] = '';
      return;
    }
  }
}
saltednut’s picture

That is a nice workaround for the bean_ui class (custom beans) since we aren't able to actually edit the class itself.

Using similar login return; (returning nothing), we've modified both bean_tax classes accordingly in 7.x-2.x - 18e6d9f (see dsdeiz commits from Nov 21 as well: http://drupal.org/node/1376658/commits)

Will work on backporting this to 7.x-1.x next.

saltednut’s picture

Status: Closed (fixed) » Active

Here is the 1.x commit: 68da539 - changes are in dev.

I'm not tagging a release yet as this creates a new bug that we'll need to chase. (see below)

The issue with an empty return statement is that the actual page render of a bean is also cancelled.

Using a hide_empty variable set to TRUE, you'll se a WSOD at http://yoursite.com/block/[block-machine-name]

Probably not a showstopper as long as you aren't planning on using the actual page callbacks.

Still, it warrants an issue of its own #1851050: return_empty variable also cancels bean view pages when set to TRUE

saltednut’s picture

Component: Miscellaneous » Code
Status: Active » Closed (fixed)

Status: Active » Closed (fixed)