I have created a block view which requires a content ID contextual filter.

When I use this block view in a display suite block field, I'm presented with a select list to choose the value to pass to the filter - but the list is empty. How can I get the node ID of the entity where the ds field is being displayed to appear here?

Comments

Leo Pitt created an issue. See original summary.

nedjo’s picture

Project: Display Suite » Drupal core
Version: 8.x-3.x-dev » 8.4.x-dev
Component: Code » block.module
StatusFileSize
new10.54 KB
new11.27 KB

This question relates to Drupal core rather than Display Suite.

What you're seeing is a result of #2377757: Expose Block Context mapping in the UI and #2287073: Allow views contextual filters to expose the context using argument validation plugins. The first issue made any contexts set for a block to show up in the UI. The second made blocks able to map contexts to the contextual filters (arguments) in views block displays.

To get an option to show up in the select when configuring the block, you need to set validation on the contextual filter. Specifically:

  • In your view, create a block display.

  • In the block display, add the contextual filter "Content: ID". Under "When the filter value IS available or a default is provided", check "Specify validation criteria" and select the "Content" validator. Save.

  • When you place the block, the select for "Content: ID" should now show "Node from URL".

nedjo’s picture

leo pitt’s picture

Thanks

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

kreatil’s picture

I have set up a block view with a contextual filter that is based on a field value. How would I set up the block configuration (admin/structure/block) to pass a value to the view? Inside the block configuration, the contextual field is being shown to me, but it only comes along with an empty select list. Inside the view I already played around with validation criteria, but without success.

lblestel’s picture

Same as @kreatIL.
Because I need to display view blocks with data of several node fields, and I can't use the URL to get them (too ugly).

Anybody has an idea?

I've explored contexts of panelizer module, but I can't reach to properly set a context without breaking my website

joarferme’s picture

I was able to pass the values using Panelizer and contextual filter "Raw value from the URL".

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

slayer722’s picture

Hello,

I'm looking forward to do a similar thing as explained by @nedjo, but with a specific text field from the node that contain the custom block field.
This block field contains a view with a contextual filter for this specific field by I didn't find the way to configure and pass the value from the node to the view.
I tried with "Validator = Field" but it always shows "Empty" in "Display Suite/Fields/Edit a block field/Block config"
Hope there is way, I prefer to avoid to write code in a custom module.

Thanks in advance for your help.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

devkinetic’s picture

I've been dealing with this, and I was able to work through it using the suggestions in #2. When using display suite also going into the block field config and selecting the argument from the dropdown.

Where I keep running into issues is when I have a contextual filter set to "fixed" on the block view. This flat out doesn't work. I tried setting the validation to "basic" and still nothing. To confirm I am able to render the same block through the block system without issue.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dmezquia’s picture

StatusFileSize
new65.45 KB

I need to expose taxonomy terms.

- I select in validation, taxonomy ID and it does not works?!?!? some solution?

Tid

devkinetic’s picture

@dmezquia You need to edit the block field in display suite, as well as the view. The path to this page will look like this: /admin/structure/ds/fields/manage_block/***FIELD_NAME***/block_config. You have to select your argument from the select and hit save.

dmezquia’s picture

@devkinetic I need this exposed tids filters for layout builder block, iam not using in this case display suite.

anruether’s picture

@dmezquia Maybe you are looking for ctools_views plus #2759445: How to manually pass an argument to a views block through interface ?

kreatil’s picture

A workaround to accomplish this ("passing a value into a views contextual filter from a block field") would be to use Custom blocks. In my use case, I created a custom block type and added a Views Reference Field to it. Maybe the issue is even solved with this solution.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

init90’s picture

Component: block.module » views.module
Status: Active » Closed (works as designed)

Initial problem was resolved.

thomasmurphy’s picture

This solution only works for the full node view where the raw path is available, not for when the node is viewed elsewhere.

zserno’s picture

Using DS, patch #14 from #2939322: Provide entity context to DS block fields fixed my issues.