Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When retrieving results of a view using the function views_get_view_result(), filtering content's language to be the current user's language won't work + translatable fields won't be translated, they will always be displayed in the site's default language.
The current user's language should be added to the context of the function.
If I'm right this works correctly with the function views_embed_view()
Comments
Comment #1
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedSwitching to bug report as I think it is more appropriated.
Comment #2
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedAny one ? Any advice where I should be looking ?
Comment #3
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedI finally got my answer from an issue posted on Views : http://drupal.org/node/1901214
First I was wrong about the filtering by current user's language not working, it is actually working so the function views_get_view_result() is indeed current user's language aware. However, I learnt that this function is designed to bring back « raw » data and that « raw » data means « not translated » data.
I personally think it would be great to have a way to retrieve « translated raw data » from Views.
For now I shared on the post above the way I did it but I would be interested to know what you guys think about it, what could be done and what couldn't.
Comment #3.0
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedPart of the problem was not real