Is there a context condition for views in the 8.x version? I want to have some blocks appear only when viewing specific views, and I would prefer to not base it on a path.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

meecect created an issue. See original summary.

Janez Zibelnik’s picture

Version: 8.x-4.0-beta2 » 8.x-1.x-dev
Status: Active » Needs review
FileSize
3.74 KB

Hi, I created a patch for this.

Janez Zibelnik’s picture

Version: 8.x-1.x-dev » 8.x-4.x-dev
icurk’s picture

Status: Needs review » Needs work

The patch works great. But please add dependency injection for \Drupal::routeMatch() service, which is used in evaluate method on line 106.

Janez Zibelnik’s picture

Status: Needs work » Needs review
FileSize
4 KB

Created a new patch adding the dependency injection for \Drupal::routeMatch().

Janez Zibelnik’s picture

I used the wrong namespace in my previous patch. Sorry about that. Here is the fixed patch.

icurk’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the patch. It looks good now. Thanks.

  • boshtian committed c4be6a3 on 8.x-1.x authored by janezzibelnik
    Issue #2938094 by janezzibelnik, icurk: Where is the views condition on...
boshtian’s picture

Status: Reviewed & tested by the community » Fixed

  • boshtian committed c4be6a3 on 8.x-4.x authored by janezzibelnik
    Issue #2938094 by janezzibelnik, icurk: Where is the views condition on...

Status: Fixed » Closed (fixed)

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

FrancescoQ’s picture

I've just updated to the last dev updated on 2018-03-20T07:43:18+00:00 as i can see from my composer.lock.
When i try to add the View inclusion condition I receive an ajax error and it says:

TypeError: Argument 4 passed to Drupal\context\Plugin\Condition\ViewInclusion::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in /var/www/html/web/modules/contrib/context/src/Plugin/Condition/ViewInclusion.php on line 56 in Drupal\context\Plugin\Condition\ViewInclusion->__construct() (line 36 of modules/contrib/context/src/Plugin/Condition/ViewInclusion.php).