Reputation: 1031
I would like to create a sitemap via TypoScript which does also include links to all available translations. Unfortunately the special=language feature does only work for the current page, not for multiple pages. A combination of a regular HMENU with special=language menus in its items would be perfect.
My approach:
lib.menu = HMENU
lib.menu {
entryLevel = 0
1 = TMENU
1{
expAll = 1
NO{
doNotShowLink = 1
allWrap{
postCObject = COA
postCObject{
stdWrap.wrap = <url>|</url>
1 = TEXT
1{
typolink.parameter.field=uid
typolink.returnLast = url
wrap = <loc>|</loc>
}
2 < .1
2.typolink.additionalParams = &L=1
2.wrap = <xhtml:link rel="alternate" hreflang="en" href="|" />
}
}
}
}
2 < .1
3 < .1
}
That almost works, but unfortunately links will also be generated for non-available translations.
Upvotes: 1
Views: 114
Reputation: 1633
You can check if the translated page is exists using the typoscript select query :
2.if.isTrue.numRows {
table = pages_language_overlay
select {
languageField = 0
where = sys_language_uid = 1
pidInList.field = uid
}
}
Note: languageField
is for selecting the language field, we need to disable in order to set sys_language_uid
field in where clause. For disabling languageField
we need to set languageField = 0
. Check more information here.
Upvotes: 1
Reputation: 10800
As you already said: you generate Links for pages where no translation exists.
But you have the option to use conditions.
Add an stdWrap.if
and check for existence of a translation of that page:
postCObject {
: as above
2.if.isTrue.cObject = CONTENT
2.if.isTrue.cObject {
table = pages_languages_overlay
select {
# get records in current page
pidInList.field = uid
# ignore current language
languageField = 0
# build individual selection on language 1
where = sys_language = 1
selectFields = uid
}
renderObj = TEXT
renderObj.field = uid
}
}
Upvotes: 1