0

There is ton of materials how to do it in 7, but I was not able to find or adapt based on those solutions.

My View has fields:

  • Content: Title
  • Title first letter [hidden]

Filters:

  • Content: Publishing status (= Yes)
  • Content: Content type (= Basic page)
  • Content: List page in glossary (= True)

Sort criteria: - Content: Title (asc)

Relationships: - Node

Rendering Language: Interface text language selected for page

When viewing page with default language (which is a source language for a nodes) sorting is working good. After switching language sorting not working well, seems like it's based on source translation content every time.

Generated SQL:

SELECT node_field_data.title AS node_field_data_title, node_field_data.nid AS nid, node_taxonomy_index.nid AS node_taxonomy_index_nid
FROM 
{node_field_data} node_field_data
LEFT JOIN {taxonomy_index} taxonomy_index ON node_field_data.nid = taxonomy_index.nid
LEFT JOIN {node} node_taxonomy_index ON taxonomy_index.nid = node_taxonomy_index.nid
LEFT JOIN {node__field_glossary_enabled} node__field_glossary_enabled ON node_field_data.nid = node__field_glossary_enabled.entity_id AND (node__field_glossary_enabled.deleted = '0' AND node__field_glossary_enabled.langcode = node_field_data.langcode)
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('page')) AND (node__field_glossary_enabled.field_glossary_enabled_value = '1')
ORDER BY node_field_data_title ASC
7
  • You probably need to add a filter for the language, see drupal.stackexchange.com/questions/261401/…
    – 4uk4
    May 29, 2018 at 9:57
  • @4k4 for me it's not available on filter list ...
    – Codium
    May 29, 2018 at 10:27
  • The linked question was for a View based on Taxonomy, but there is a filter "Translation language" for all translatable entities, also for nodes (Content in Views).
    – 4uk4
    May 29, 2018 at 11:14
  • I've ended using: Rendering Language: Content language of view row & Contextual Filters: Content: Translation language. Don't know why but in Content: Translation language there is no option for current user language, maybe because this view is block only.
    – Codium
    May 29, 2018 at 12:11
  • Normally you filter (normal filter, not contextual) the language detected for the user interface or content (if you have configured content language detection separately).
    – 4uk4
    May 29, 2018 at 12:55

1 Answer 1

1

Now you get view rows for the original language and sort them still untranslated, because you translate them later when rendering.

You need to filter the rows for the current language to be able to sort the translated titles:

enter image description here

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.