When a block is added to the homebox and it is empty or has no content, it will still be rendered.

Only render the empty blocks when the user has role "administrator" for other roles do not render the empty blocks.

Probably the rendering of the empty blocks should be controlled by a permission.

Comments

bonrita created an issue. See original summary.

bonrita’s picture

Fix

bonrita’s picture

Issue summary: View changes
bonrita’s picture

Issue summary: View changes
bonrita’s picture

Issue summary: View changes
bonrita’s picture

Add an event that can be used by developers to add logic that will control visibility of a block e.g check for view blocks who have empty content.

For example

class HomeboxSubscriber implements EventSubscriberInterface {

  public static function getSubscribedEvents() {
    $events[HomeboxEvents::BLOCK] = 'onBlockPlacement';
    return $events;
  }

  /**
   * Checks if block should be placed on the page.
   *
   * @param \Drupal\homebox\Event\HomeboxBlockEvent $event
   *   The homebox block event.
   */
  public function onBlockPlacement(HomeboxBlockEvent $event) {

    if($event->getBlock() instanceof ViewsBlock) {
      $noContent = !isset($event->getRenderArray()['render']['#block_content']['view_build']) || empty($event->getRenderArray()['render']['#block_content']['view_build']['#rows']);
      if($noContent && !in_array('administrator', $event->getAccount()->getRoles())) {
        $event->setIsEmpty(TRUE);
      }
    }
  }

}
drumm’s picture

I think homebox should simply not render empty blocks, following the lead of the core block system. Is there any parallel to this in the block system, or core layouts? If a module is adding an empty block that needs more configuration, it should provide a message pointing the user toward what to do next.

bonrita’s picture

Assigned: bonrita » Unassigned
anybody’s picture

I think homebox should simply not render empty blocks, following the lead of the core block system. Is there any parallel to this in the block system, or core layouts? If a module is adding an empty block that needs more configuration, it should provide a message pointing the user toward what to do next.

Agreed!

anybody’s picture

Status: Active » Needs review
anybody’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
anybody’s picture

Version: 2.0.x-dev » 3.0.x-dev
anybody’s picture

Status: Needs review » Postponed

Let's check if this is still an issue in 3.0.x once alpha has been released.

anybody’s picture

Assigned: Unassigned » anybody

We'll solve this in 3.0.x-dev!

anybody’s picture

Assigned: anybody » thomas.frobieter
Status: Postponed » Needs review

@thomas.frobieter I think this is solved in 3.0.x as of our last talk?

thomas.frobieter’s picture

Status: Needs review » Fixed

Yes, this is the default behavior of the 3.x default layout, so this is fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.