0

As part of a migration from drupal 7 to drupal 8, I currently have a rather original node display method that I'm trying to reproduce to Drupal 8, but without success. Currently on Drupal 7, this method is filled by a custom preprocess that I try to remove in favor of views / entity reference.

Here is the procedure: I have a node type that contains tags (field_tags), with for example the vocabulary 'news' from the 'Users terms' term. And basic content (title, body...). I would like, via an already existing block having a field tags and value 'news', recover all the nodes with the tag 'news'.

Recap of entities I have tried:

Node: - title - body - field_tags / value: 'news' (reference to "User terms")

Views name 'flow': - display: content - contextual filter: 'Content: Has taxonomy term ID' > 'Display all results for the specified field' & Content: Nid - relationsips: nothing, because I can't add a entity reference to a block

Block name 'block flow' : - title - field_tags / value: 'news' (reference to "User terms")

I would like when I create a block type 'block flow' with 'news' tags, get all node type that containing the 'news' tag.

I can't get it working because the views relationships don't allow me to reference the field 'field_tags' from my block (only content or taxonomy available). We have a theme preprocess who can do that but I would like to know if there is a workaround ou any contrib module doing that.

Why I don't create a block from the view? Because in our process, we don't give access to the views of our contributors.

0

1 Answer 1

0

Finally, I got this working by creating a simple view "custom block". Then, I created 3 relations, one for my node content, one for my content tags and last one for block tags

After that, we just need a contextual filter : Content: Has taxonomy term ID' > 'Display all results for the specified field

And that's all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.