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.
Related
How to make this HMENU display only the available pages?
Hope it is clear: at the moment it displays links for pages that lead to a 404 - Page not found
20 = HMENU
20 {
special = language
special.value = 0,1,2,3,4,5,6
special.normalWhenNoLanguage = 0
1 = TMENU
1 {
wrap (
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
|
</div>
</div>
</div>
)
NO = 1
NO {
doNotLinkIt = 1
linkWrap = |
stdWrap {
typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1 || &L=3 || &L=4 || &L=5 || &L=6 || &L=7 || &L=8 || &L=9
ATagParams = class="dropdown-item"
addQueryString = 1
addQueryString.exclude = L,id,no_cache
addQueryString.method = GET
no_cache = 0
}
}
}
ACT < .NO
ACT {
stdWrap {
typolink {
#Add class to disable already active language from dropdown items
ATagParams = class="disable-link-content"
}
}
}
USERDEF1 < .NO
USERDEF1 {
noLink = 1
}
USERDEF2 < .ACT
USERDEF2 {
noLink = 1
}
}
#2 < .1
#3 < .2
}
If more information is required please let me know..
there is no noLink option (although the manual of TYPO3 9 does include it in an example, which gets removed now)
use doNotLinkIt = 1
oh. as you already use it and generate the link on your own with stdWrap.typoLink you need to remove this link generation.
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 am currently working on a project that requires two languages. For example German (L=0) and Leicht German (L=1).
My goal is, when there is a translation available on the German page to Leicht German, a button will appear and redirect the user to the Leicht German language. So far so good it works.
But, when you are on the Leicht German version and you want to move to another page where no Leicht German translation is available, by clicking on the submenu and not the button itself, the URL stays on the L=1 and it doesn't go back to L=0.
I would like your knowledge on this matter cause i am run out of ideas.
Here is my code:
config {
linkVars = L(0-1)
uniqueLinkVars = 1
defaultGetVars.L = 0
sys_language_uid = 0
sys_language_overlay = 1
language = de
locale_all = de-DE
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = leichte Sprache
locale_all = de_DE.UTF-8
htmlTag_setParams = lang="ls" dir="ltr" class="no-js" }
[global]
This is my list where when you click you redirect to the Leicht German and backwards.
lib.language = COA
lib.language {
20 = HMENU
20 {
special = language
special.value = 0,1
special.normalWhenNoLanguage = 0
wrap = <ul class="languageMenu">|</ul>
1 = TMENU
1 {
noBlur = 1
NO = 1
NO {
linkWrap = <li>|</li>
stdWrap.override = Deutsch || Leichte Sprache
stdWrap {
typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1
ATagParams = hreflang="de-DE" || hreflang="de-LS"
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 < .NO
USERDEF1 {
linkWrap = <li class="text-muted">|</li>
stdWrap.typolink >
}
}
}
}
This is the submenu where when you click and no translation is available it should redirect the user to the default language (L=0)
lib.subnav = HMENU
lib.subnav.entryLevel = 1
lib.subnav {
1 = TMENU
1 {
wrap = <ul class="side-nav">|</ul>
noBlur = 1
NO = 1
NO {
wrapItemAndSub = <li>|</li>
ATagTitle.field = title
typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1
ATagParams = hreflang="de-DE" || hreflang="de-LS"
addQueryString = 1 addQueryString.exclude = L,id,cHash,no_cache
addQueryString.method = GET
useCacheHash = 1
no_cache = 0
}
}
ACT < .NO ACT {
ATagParams = class="active" wrapItemAndSub = <li class="active">|</li>
}
}
At this point i have nothing else to add. If you need more from me, feel free to ask.
Thanks in advance,
Aris
did you try this, just let typo3 take care of the link:
lib.subnav = COA
lib.subnav {
10 = HMENU
10 {
entryLevel = 1
1 = TMENU
1 {
expAll = 1
wrap = <ul class="side-nav">|</ul>
noBlur = 1
NO = 1
NO {
wrapItemAndSub = <li>|</li>
ATagParams = title="{field:title}"
ATagParams.insertData = 1
}
ACT < .NO
ACT {
wrapItemAndSub = <li class="active">|</li>
ATagParams = class="active"
}
}
}
}