0

I have a 'business' content type and an 'information' content type on my page. The author of the business is the webmaster and from the information the authors are the users of the site. The contenttype 'business' has an entity reference field targeting the users linked to that business

On the 'business' pages there is a block showing the 'information'articles published by the users linked to that specific business. So far no problem.

I would like to have a block on the 'information' pages showing the business the author of that node/article is linked to. The author of the contenttype business is always the webmaster and the author of the article is the user. I think that I don't understand the relationship that I must make to get this correct. The block has to look at the author of the node where the block is displayed and see the business where that user is linked to.

I'm completely blocked getting that done. I'm new to Drupal, there were no serious problems so far. But this I can't get done.I'm missing something in the contextual filters and relationships.

1

You've stumbled into the issue of Context. Blocks can be placed anywhere, and has a very limited concept of context (the only context that Blocks know of are logged in user, and parameters taken from the url).

Normally one will use CTools (the Context specialist) and Panels to solve this type of problem. You are lucky in that Views has a relationship that can solve it for you.

Construct your block as follow:

Type Content, filtered by content type Information.

Contextual filter:

Content: Nid (The node ID.), no relationship, and for WHEN THE FILTER VALUE IS NOT AVAILABLE you add Content ID from URL

Relationships:

  1. Content: Author (Relate content to the user who created it.), and Require this relationship

  2. Entity Reference: Referencing entity (A bridge to the Content entity that is referencing User via field_users - Your field will be differently named, mine is field_users). Set the relationship to 'author' (the first relationship added), and Require this relationship.

Fields:

I assume you are adding the node title. Make sure to set the relationship to: Content referencing Users from field_users (the 2nd relationship you added - yours will be named slightly different)

If you add any other fields make sure to set the relationship as well.

If you find that it lists any duplicates, just go to OTHER in views, and under Query Settings, set it to Distinct (I'm sure this won't be necessary though).

0

Thanks very much for your quick reply! Really appreciate it.

The setting u describe is the way i have the blocks working on the nodes with the 'business' content. The blocks show the articles written by the users that are linked to that business.

I cant get it working the other way around. On the 'article' nodes i would like to have a block that shows the business that the author of that particular node is linked to. I was thinking that the problem is maybe in the relationship author. The contenttype business has as author the webmaster and not the users of the site who are writing the articles.

Could that be? English is not my mothertongue.. so maybe i completly misunderstand?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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