I've created a multilingual TYPO3 6.2 website with fluid and Gridelements.
I have a big Problem with the language translations (btw: same problems occur in TYPO3 7.6)
If I create an alternative page language with no content inside, I want to show the default language, in my case German.
Otherwise, if there is some content on the translated (english) site, the german default should be hidden and the complete alternativ language content should be visible.
In my case it is only possible to translate exakt these parts from the german default language and it is not possible to create some new content which is not shown in the default language. In the TYPO3-backend I can create the new content, but it will not be shown.
If I set config.sys_language_overlay = 0 at Typoscript, the new content is visible, but the complete default content isn't shown.
Which Settings are necessary to show the complete content at the alternative language and the default content for empty pages?
This is what I have tried so far:
styles.content.get.select.includeRecordsWithoutDefaultTranslation = 1
styles.content.getLeft.select.includeRecordsWithoutDefaultTranslation = 1
styles.content.getRight.select.includeRecordsWithoutDefaultTranslation = 1
And here my Typoscript
### language Menü ###
lib.langselect = COA
lib.langselect {
wrap = <ul class="langNav">|</li></ul></ul>
30 = HMENU
30 {
special = language
special.value = 0,1,7
special.normalWhenNoLanguage = 0
1 = TMENU
1 {
noBlur = 1
# Standard Sprachen
NO = 1
NO {
linkWrap = <li>|</li>
stdWrap.override = Deutsch /|| English /
doNotLinkIt = 1
stdWrap.typolink.parameter.data = page:uid
stdWrap.typolink.additionalParams = &L=0 || &L=1
stdWrap.typolink.addQueryString = 1
stdWrap.typolink.addQueryString.exclude = L,id,cHash,no_cache
stdWrap.typolink.addQueryString.method = GET
stdWrap.typolink.useCacheHash = 1
stdWrap.typolink.no_cache = 0
}
ACT < .NO
ACT.linkWrap = <li class="active">|</li>
USERDEF1 < .NO
USERDEF2 < .ACT
}
}
}
config.linkVars = L
config.locale_all = de_DE
config.sys_language_uid = 0
config.sys_language_mode = content_fallback
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.sys_language_overlay = 1
config.metaCharset = iso-8859-1
config.locale_all = en_GB.ISO88591
config.language = en
[GLOBAL]
[globalVar = GP:L = 7]
config.sys_language_uid = 7
config.metaCharset = iso-8859-1
config.locale_all = fr_FR.ISO88591
config.language = fr
[GLOBAL]
And here’s the script where I load the content to my lib-field:
lib.contentmid = HMENU
lib.contentmid {
1 = TMENU
1 {
expAll = 1
NO = 1
NO {
ATagParams = class="notUsableLink"
wrapItemAndSub.insertData = 1
wrapItemAndSub = <section id="{field:subtitle}">|</section>
allWrap = <div class="mainContent"><div class="contentHolder">|</div></div>
before = <div class="hideLink" data-link="{field:subtitle}">{field:title}</div>
before.insertData = 1
after.cObject = CONTENT
after.cObject {
table = tt_content
select {
orderBy = sorting
pidInList.field = uid
languageField=sys_language_uid
where = colPos = 2
}
}
}
}
2 < .5
2 {
wrapItemAndSub.insertData = 1
NO.wrapItemAndSub = <div id="{field:subtitle}" class="subContent"><div class="contentHolder">|</div></div>
NO.allWrap >
}
}
Any idea? Many thanks.
Add 'includeRecordsWithoutDefaultTranslation = 1' to 'after.cObject.select.' The styles.content.get is some kind of shortcut for colPos 0 ... 3, but does not affect your TypoScript at this point.
In TYPO3 version 11 the problem might occur at least for extbase extensions too.
This case can be solved with the extension https://github.com/georgringer/extbase_with_no_l10n_parent.
Related
I would like to maintain the hreflang for pages in Typo3 7.6.19.
This is not possible automatically, because the pages are external and different.
With Yoast-SEO this possibility (at least in my version) does not come along.
It is an old Typo3 version, so I cannot use the extension bgm_hreflang from the TER.
Anyone an idea?
The structure of the hreflang meta is known.
https://developers.google.com/search/docs/advanced/crawling/localized-versions
I think I found out. I checked at which position the hreflang was generated:
headerData {
10 = HMENU
10 {
special = language
special.value = 0,1
special.normalWhenNoLanguage = 0
1 = TMENU
1 {
NO = 1
NO {
stdWrap.cObject = TEXT
stdWrap.cObject {
value = de || en
}
linkWrap = <link rel="alternate" hreflang="|
doNotLinkIt = 1
after.cObject = TEXT
after.cObject {
stdWrap {
wrap = " href="|" />
typolink {
parameter.data = TSFE:id
#page:uid
additionalParams = &L=0 || &L=1
returnLast = url
forceAbsoluteUrl = 1
addQueryString = 1
addQueryString.method = GET
addQueryString.exclude = gclid,L,id,cHash,no_cache,backPid
}
}
}
}
CUR = 1
CUR.doNotShowLink = 1
# No Translation
USERDEF1 = 1
USERDEF1.doNotShowLink = 1
USERDEF2 < .CUR
}
}
}
And then overwritten by the template extension per page:
page.headerData.10 >
page.headerData.10 = TEXT
page.headerData.10.value (
(...)
<link rel="alternate" href="https://example.com/" hreflang="x-default" />
)
Of course, it would be nicer if the editor would only have to enter urls as HTML code, but for the moment it fits.
For the generation of the canonical tag by typoscript, I need to check if the current page is translated. If not, the canonical needs to point to the url in default language.
How can I check if current page is translated by typoscript?
Language handling in my typoscript config:
sys_language_overlay = 1
sys_language_mode = content_fallback
If anyone is interested, I have worked out a solution to my task: Render the canonical url in default language if there is no translation for the current page (content_fallback)
page.headerData.10 = COA
page.headerData.10 {
10 = LOAD_REGISTER
10.isPageTranslated.cObject = CONTENT
10.isPageTranslated.cObject {
table = pages
select {
selectFields = plo.sys_language_uid
pidInList = {$config.rootPid}
join = pages_language_overlay plo ON plo.pid = pages.uid
where = plo.pid = ###pid### AND plo.sys_language_uid = ###lang### AND plo.deleted = 0 AND plo.hidden = 0
markers {
pid.data = page:uid
lang.data = page:sys_language_uid
}
}
renderObj = TEXT
# translation available
renderObj {
wrap = <link rel="canonical" href="|">
typolink {
parameter.data = TSFE:id
returnLast = url
}
append = TEXT
append.value (
)
}
}
20 = TEXT
20 {
data = register:isPageTranslated
ifEmpty {
# no translation available
wrap = <link rel="canonical" href="|">
typolink {
parameter.data = TSFE:id
additionalParams = &L=0
returnLast = url
}
append = TEXT
append.value (
)
}
}
}
I want to hide a language from my language menu if a news record is not translated.
The following setup works perfectly for pages. So if a page has no translation, the "English" is not shown in the language menu on the website.
I would like to have this behaviour for not translated news records as well.
The language menu so far:
lib.language = COA
lib.language {
20 = HMENU
20 {
special = language
special.value = 0,1
special.normalWhenNoLanguage = 0
wrap =
1 = TMENU
1 {
noBlur = 1
NO = 1
NO {
linkWrap = <li>|</li>
stdWrap.override = Deutsch || English
stdWrap {
typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1
ATagParams = hreflang="de-DE" || hreflang="en-GB"
addQueryString = 1
addQueryString.exclude = L,id,cHash,no_cache
addQueryString.method = GET
useCacheHash = 1
no_cache = 0
}
}
}
ACT < .NO
ACT.linkWrap = <li class="active">|</li>
USERDEF1 = 1
USERDEF1 {
ldoNotLinkIt = 1
stdWrap.cObject = TEXT
stdWrap.cObject.value =
}
USERDEF2 = 1
USERDEF2 {
doNotLinkIt = 1
stdWrap.cObject = TEXT
stdWrap.cObject.value =
}
}
}
wrap = <ul id="language_menu" class="language-menu">|</ul>
}
My typoscript configuration:
config.sys_language_mode = strict
config.sys_language_overlay = hideNonTranslated
LocalConfiguration.php
[FE][hidePagesIfNotTranslatedByDefault] = 1
You have to manually set the USERDEF1 state. This Utility class should help: https://gist.github.com/birger-fuehne/a8a97c94ec9346d691174462ccbfcfcc
I want to render all pages into the template to make a onepager
I try this:
page.20 = TEMPLATE
page.20.template = FILE
page.20.template.file = fileadmin/design/index.html
page.20.marks{
lib.sectionContent = HMENU
lib.sectionContent {
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap >
stdWrap {
cObject = COA
cObject {
if.value = 4
if.equals.field = doktype
if.negate = 1
10 < temp.titleSectionId
10.wrap = <section id="|">
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
}
wrap = <div class="container">|</div>
renderObj < tt_content
}
30 = TEXT
30 {
wrap = </section>
}
}
}
}
}
}
LANGMENU < temp.langMenu
In the Template File I have a section ###CONTENT###
And I want that all contents were printed there. How would that be possible?
You have a nesting error.
Your nesting currently looks like this (verify with the object browser):
page.20.marks.lib.sectionContent ...
However the the TEMPLATE object at page.20 checks only for keys in .marks.* and expects a valid content object (cObject) configuration there. However the valid key lib has no cObject set.
What you really try to do is this:
# prepare configuration for content
lib.sectionContent = HMENU
lib.sectionContent {
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap >
stdWrap {
cObject = COA
cObject {
if.value = 4
if.equals.field = doktype
if.negate = 1
10 < temp.titleSectionId
10.wrap = <section id="|">
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
}
wrap = <div class="container">|</div>
renderObj < tt_content
}
30 = TEXT
30 {
wrap = </section>
}
}
}
}
}
}
# initialize configuration for the default page object
page.20 = TEMPLATE
page.20.template = FILE
page.20.template.file = fileadmin/design/index.html
page.20.marks{
# copy the configuration from above to the right place
CONTENT < lib.sectionContent
# I really hope that you prepared temp.langMenu beforehand
LANGMENU < temp.langMenu
# close block for page.20.marks
}
I want to create a typolink from the current page but with other name and some additional GET parameter. E.g.
My custom name
This is my code which only prints out a text with MyCustomName.
lib.tsfooter >
lib.tsfooter = COA
lib.tsfooter {
10 = TEXT
10.value (
<!-- some HTML code-->
)
20 = TEXT
20.value = MyCustomName
20.stdWrap.typolink {
data = TSFE:id
addQueryString = 1
addQueryString.method = get
additionalParams = &myCustomParameter=1
}
}
What I'm doing wrong?
lib.tsfooter >
lib.tsfooter = COA
lib.tsfooter {
10 = TEXT
10.value (
<!-- some HTML code-->
)
20 = TEXT
20.value = MyCustomName
# you do not need "stdWrap" as pgampe mentioned, but it will work even with stdWrap
20.stdWrap.typolink {
# parameter was missing
parameter.data = TSFE:id
addQueryString = 1
addQueryString.method = get
additionalParams = &myCustomParameter=1
}
}