简体   繁体   中英

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.

But how can I achieve this in normal typolinks or fluid "<f:link.page uid="..."> without manually dealing with the language?

I'm on typo3 9.5.

Sample: I have the following polish URL:

mydomain.com/pl/poland/

All the links from this page should go to "/en/subpage-xy/" because the above page is the only page translated to "pl". But actually all links go to "/pl/subpage-xy/" regardless if pages are translated to "pl".

The content-fallback mode leads to displaying english content under a /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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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