Mentioned in #1801304-316: Add Entity reference field Task B.


Cannot figure out how to add a context that will get default argument of nid's translation's language (from the url) and use that to filter a list of users by those users who have the same langcode in their account language setting.

Proposed resolution


Remaining tasks

It may not be possible. See what Tim or Daniel says.

User interface changes


API changes


#9 view.txt5.35 KBYesCT


YesCT’s picture

Here are notes from a poor first attempt:

  1. add view. name: language user list
  2. show: users (meh, cannot pick default sort by name.)
  3. Save and edit
  4. add entity reference display
  5. notice error and click the format settings link.
  6. check user name and click apply.
  7. preview lists all users.
  8. add filter criteria: User: language. click apply (all displays)
  9. operator: is one of
  10. language checkboxes.. want to pick, get default from url or something. dont see that. click more collapsed field set, but that's just administrative title
  11. try not picking any checkbox.
  12. click apply.
  13. get error: No valid values found on filter: User: Language.
  14. add sort criteria: user: name
  15. click apply
  16. click rearrange in sort criteria drop button. put user: name (asc) first.
  17. click advanced
  18. click add next to contextual filters. try global null.
  19. pick provide default value
  20. try type: content id from url
  21. (advanced column keeps staying collapsed)
  22. go back to filter criteria user: language

maybe I dont want to list users. Maybe I want to list content, and then the language and then a relationship to users with that language?

dawehner’s picture

Assigned: Unassigned » dawehner
Category: support » task
Issue tags: +VDC

So there is for sure a limit what views can do out of the box.

The approach with using somehow a listing of users and try to use default argument is the right approach, though we need a new default plugin which could be called "node language from url". I'm happy to write one of those plugins.

YesCT’s picture

@dawehner if you write in words how to write a plugin like that, me or someone else can try and do the task. Maybe there is some documentation to point us to?

dawehner’s picture

Just a general question: Do you want to list all users, which have configured a certain langcode, which is the same as the langcode from the current node?

YesCT’s picture


Thinking back, I was testing the entity reference addition and wanted to see if with worked with multilingual.
I think I was imagining that I wanted to fill in some (reference) to a user, and wanted to use language to limit all the users on a site, to just those users with the same language (default language setting) in their account as the language of the node being edited.

But I imagine, that something similar would be involved in making a block of 5 users for display with a piece of content, if we wanted to limit the list of users to those that had selected the same language as the content was.

YesCT’s picture

Actually, thinking more.. are users... do they have a "language" associated with the actual user, not their setting of what they want the default language of content to be is... but the language of the user thingy itself... like the language of the profile.

Say a user has a job title field. That user can write the name of their job title there, and translate it. So the 'user' itself might exist in one language and their might be translations of that user too.

We can probably come up with a reason to want to filter users by that kind of language also.

dawehner’s picture

Issue summary: View changes

Is this issue still relevant?

Gábor Hojtsy’s picture

YesCT’s picture

5.35 KB

I went back again, and still could not figure out how to make a block of usernames whose preferred language was af, when viewing a translation of a node into af: af/node/1

"language of the content" seems to always be english... from the context? (views ui preview) maybe it is just the preview!
tried saving and viewing the block placed in the sidebar of a en node translated into af, and an af node translated into en
this exported block seems to work.
but does not use entity reference.

maybe I'm not sure how to use an entity reference view anymore... I'll think on it. for now. here is the view block export.

YesCT’s picture

I added an entity ref display view to the view, I added an entity ref field to the article content type, picked user, and selected the ER view for the field. but when editing node/1/edit (or af/node/1/edit) the ER field autocomplete does not complete, the spinny wheel does not spin.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

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