简体   繁体   English

TYPO3 创建链接并尊重目标页面的语言(流体,错字链接)

[英]TYPO3 create links and respect language of target page (Fluid, typolink)

we have a webpage, where not all pages are translated.我们有一个网页,并非所有页面都被翻译。 So many pages are only available in english and some special pages (country landing pages) are translated to various languages.这么多页面只有英文版,一些特殊页面(国家登陆页面)被翻译成各种语言。

From these special translated pages I want to create links automatically converted to the default languages if the target page is not translated.如果目标页面未翻译,我想从这些特殊的翻译页面创建自动转换为默认语言的链接。

In menus (HMENU) "protectLvar = 1" works fine for me.在菜单(HMENU)中,“protectLvar = 1”对我来说很好用。

But how can I achieve this in normal typolinks or fluid "<f:link.page uid="..."> without manually dealing with the language?但是如何在不手动处理语言的情况下在普通的错字链接或流畅的“<f:link.page uid="..."> 中实现这一点?

I'm on typo3 9.5.我在 typo3 9.5 上。

Sample: I have the following polish URL:样品:我有以下波兰语 URL:

mydomain.com/pl/poland/ mydomain.com/pl/波兰/

All the links from this page should go to "/en/subpage-xy/" because the above page is the only page translated to "pl".这个页面的所有链接都应该 go 到“/en/subpage-xy/”,因为上面的页面是唯一翻译成“pl”的页面。 But actually all links go to "/pl/subpage-xy/" regardless if pages are translated to "pl".但实际上所有链接 go 到“/pl/subpage-xy/”,无论页面是否翻译为“pl”。

The content-fallback mode leads to displaying english content under a /pl/-URL.内容回退模式导致在 /pl/-URL 下显示英文内容。 I don`t want to change the fallback mode - I only want the links to be created to available language of the target page.我不想更改回退模式 - 我只想创建指向目标页面可用语言的链接。

Is this possible?这可能吗? Many thanks for any hints.非常感谢任何提示。

I think that you can't achieve what you want with default behavior.我认为你无法通过默认行为实现你想要的。

I suggest you to wrote your own view helper based on <f:link.page> and in that view helper, you can check with a request in the DB if the page exist for the current language and switch to English if that's not the case.我建议您基于 <f:link.page> 编写自己的视图助手,并且在该视图助手中,您可以检查数据库中的请求是否存在当前语言的页面,如果不是则切换到英语.

I guess that you can also generate the link with typoscript with condition over page existence in current language but it's more tricky.我想您也可以使用当前语言的页面存在条件生成带有打字稿的链接,但这更棘手。

You have a sample here: check if current page is translated您在这里有一个示例: 检查当前页面是否已翻译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM