开发者

Drupal: displaying a language switcher only when the content is translated

I have multi-language website in Drupal, but not all content is translated. I want the language switcher block to appear in a content page only if there's a translation for that content.

The language switcher block uses the function translation_path_get_translations to get the path of the translated version of the content being viewed. If there's no translated paths, the block does not print the switcher.

The problem is that sometimes the translated version is under the same path tha开发者_Go百科t the original content (e.g. when it's a view or a module-generated content). In this case, although translation_path_get_translations doesn't return any translated path, the language switcher should be printed, because the view or module will take care of the translation.

For example, these are the paths of a translated content:

english/content-path-here
portuguese/conteudo-aqui

And these are paths of a content generated by a view or module:

english/foobar
portuguese/foobar

So, is there a way to solve this? Maybe a way to determine if a given path is a "real content" (and not a view/module)?

Thanks.


hmm, i think it's possible only manually by paths.
May be help this:


if ((arg(0) == 'node') && is_numeric(arg(1))) {
  // that show you are on single node, and you can show block for translation
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜