I am developing a TYPO3 website with multilanguage support. I am using TemplaVoila for template mapping. Site works in both languages. But content added with Typoscript in TemplaVoila mapping is rendered only in default language, in other languages content from Typoscript is missing.
here is my typoscript:
lib.autherInfo = CONTENT
lib.autherInfo {
table = tt_content
select {
selectFields = cruser_id
}
renderObj = COA
renderObj {
10 = RECORDS
10{
source.field = cruser_id
tables = be_users
dontCheckPid = 1
conf.be_users = COA
conf.be_users {
10 = TEXT
10.field = realName
10.noTrimWrap = ||, |
15 = RECORDS
15{
source.field = usergroup
tables = be_groups
dontCheckPid = 1
conf.be_groups = COA
conf.be_groups {
10 = TEXT
10.field = title
10.noTrimWrap = ||, |
}
}
20 = TEXT
20.dataWrap = <span><a href="mailto:{field:email}" >{field:email}</a></span>
}
}
}
}
lib.autherInfo.wrap = <p>by: |</p>
Output mark up of above typoscript is:
<p>by: Administrator, admin, <span>admin#kultur.com</span></p>
In other languages output is:
<p>by: </p>
How to fix this?
Your question is missing your typo3 language configuration. You can set a language fallback at least to get some output. Example configuration
config {
linkVars = L
sys_language_uid = 0
language = de
locale_all = de_DE
htmlTag_langKey = de
sys_language_mode = content_fallback
sys_language_overlay = hideNonTranslated
linkVars := addToList(L)
uniqueLinkVars = 1
// content fallback
sys_language_fallBackOrder = 1,0
sys_language_mode = content_fallback ; 1,0
sys_language_overlay = 1
sys_language_content = 1
}
Try setting
sys_language_overlay = hideNonTranslated
to
sys_language_overlay = 0
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
}
}