Problem/Motivation

The block display doesn't allow exposed filters unless ajax is turned on. This seems to stem form Drupal 7 limitations. For a a view with facets to work the whole page should be refreshed, however.

Proposed resolution

Allow non-ajax blocks to have exposed filters.
This works because views always uses <current> route when view-URL/display-path is not available, for example: http://cgit.drupalcode.org/drupal/tree/core/modules/views/src/Form/Views...

Remaining tasks

Find cases where this would be problematic.
Write tests.

User interface changes

The exposed filters appear and the wtf-moment for site builders disappears.

API changes

none

Data model changes

none

Original Issue:

Exposed filters are getting lost, when view is rendered as block

If I'm creating a block which is based on the content view page (Drupal core view - ID "content"), then the view works except of the exposed filters, e.g. filter by title. You can see the view at the Drupal 8 site's URL /admin/content/node.

I'm displaying the block in my custom template. I'm getting the block markup by my following controller method:

  /**
   * Gets the HTML markup for a block by it's ID.
   *
   * @param $sBlockId The id of the block as string.
   *
   * @return string The HTML markup for the rendered block.
   */
  private function getBlockMarkupById($sBlockId)
  {
    $oBlock = \Drupal\block\Entity\Block::load($sBlockId);
    $aRenderArray = \Drupal::entityManager()
      ->getViewBuilder('block')
      ->view($oBlock);

    return \Drupal::service('renderer')->render($aRenderArray);
  }

Everything except the exposed filters is displayed. What's wrong?

I've also seen, that the exposed filters in block views are already a problem in previous versions of Drupal. See the related issues.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

jepSter created an issue. See original summary.

Peter Majmesku’s picture

Issue summary: View changes
Revathi.B’s picture

FileSize
40.61 KB

I have checked this issue in 8.2.x-dev.Its working fine.

bircher’s picture

Title: Exposed filters are getting lost, when view is rendered as block » Allow exposed form for non-ajax block displays
Version: 8.0.5 » 8.1.x-dev
Category: Bug report » Feature request
Issue summary: View changes
Status: Active » Needs review
Issue tags: +Needs tests
Related issues: +#2681947: Allow exposed-form-in-block for block displays
FileSize
637 bytes

I changed it from bug report to feature request because it works when ajax is turned on for the view.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

harings_rob’s picture

Needs a reroll for 8.3.x?

aleksip’s picture

Here is a patch for 8.3.x

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.