We've got a view like news with only English content and we're not planning to add content in other languages any time soon.
But we do have other languages (more static ones) on the page and therefore are using the language dropdown. If I'm in the view: /news.html (in English), Drupal and the language dropdown still provides es/news.html even though there are 0 news in Spanish.
How can I point the language dropdown to / in case I'm on the news view? (I could do Drupal redirects I reckon - but maybe there is a smarter solution which solves the root, not the impact?)

  • How did you implement and display the View?
    – M a m a D
    May 28, 2015 at 3:44
  • I didn't - only overtook the project. But I guess just clicking the view together. Backend is English. Filters: Content: Published (Yes) Content: Type (= News) Content: Language (= Current user's language)` One can reach the view via a menu entry. This is visible in English and correct. In the Spanish menu the view link isn't available - which is correct as well. But being on the view, the language dropdown provides the links to the view in other languages, even though it shouldn't. (So therefore google finds an empty page with a topic in a wrong language etc.)
    – Chris
    May 28, 2015 at 4:19

3 Answers 3


Applying filter while creating views. Add a new filter & select "Node translation" from the "Groups" listed and check "Node translation: Language" and click "Add". Then you can choose languages which you want to show.


  • Create Block
  • Under Visibility settings change to PHP (If PHP is not an option, go into modules and enable the PHP input method)
  • Use below code & save :
 global $language;
    $lang_name = $language->language;
    if ( $lang_name == "en" ) { return TRUE; } else { return FALSE; }

NOTE: Replace the "en" with the two letter name of what ever language you want the block to be visible for. For Example if you want your block only visible when the language is French, change "en" to "fr" .

  • Thanks for your answer. For that: "Node translation" from the "Groups" listed and check "Node translation: Language" and click "Add". Could you provide a screen shot? I only have Node translation: Child translation and can't add a language anywhere as it seems
    – Chris
    May 28, 2015 at 6:03
  • currently not possible to provide screenshots. Actually I am bit busy & it takes time. Try by your self.
    – Nishant
    May 28, 2015 at 6:17

It appears to me that your problem is that you cannot specify any filter for the language (or at least that this is part of your problem).

Therefor I think you should verify your configuration at Configuration -> Languages -> detection and selection: the order should be 'URL, Default, User', and not something like 'Default, URL, User'.

  • I didn't expect this to be that uncommon. Our languages are working fine /en /es /de /fr etc. If I create a view page: vpage1 and select all en and call it vpage1_en.html it will show all en content on the en site. The thing is .. on /es/vpage1_en.html this view is visible as well but contains no content. Or I'd need to set a handler: What if 0 content is found and then 301 or 404 or so. That would still work. But the language dropdown should know about /es/vpage1_es.html (same view other page) with the es content on it.
    – Chris
    Jun 5, 2015 at 0:27

You can also open the Views UI and in the Access Select PHP.

enter image description here

make sure the PHP Filter module is enabled.

in this field you can use the code other guys mentioned above

global $language;
$lang_name = $language->name;
if ( $lang_name == "English" ) { return TRUE; } else { return FALSE; }
  • We are just trying to get rid of the PHP Filter module. And it won't help for the language dropdown, right?
    – Chris
    Jun 5, 2015 at 0:31
  • How do you want to detect the user's language without PHP? Besides that, this module won't down your website!!!
    – M a m a D
    Jun 5, 2015 at 3:21
  • Drupal core already knows the users language. So I assumed Views could simply use this information for the view (not for the view content). Alternatively it would be nice to be able to configure view pages to appear only in a selected language. PHP Filter is currently installed and we're trying to get rid of it due to security issues - was a big topic but not my decision ;)
    – Chris
    Jun 5, 2015 at 6:51

Your Answer

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

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