Is "languageField" only available for tt_content or pages table?
I want to use the CONTENT object on an own extension table:
renderObj = CONTENT
renderObj {
table = tx_myext_domain_model_table
select {
pidInList = 28
languageField = sys_language_uid
}
renderObj = COA
renderObj {
10 = TEXT
10.field = description_short
}
}
But the translation not working. I tooked the TCA-, and SQL-settings from the tt_content. Also defined SQL-keys:
PRIMARY KEY (uid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY parent (pid,sorting),
KEY language (l18n_parent,sys_language_uid)
Can this be a bug like here described http://forge.typo3.org/issues/22406?
edited
In the file typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 7578 (TYPO3 6.1.7) you will find these lines:
if ($GLOBALS['TSFE']->sys_language_contentOL && $GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
// Sys language content is set to zero/-1 - and it is expected that whatever routine processes the output will
// OVERLAY the records with localized versions!
$sys_language_content = '0,-1';
} else {
$sys_language_content = intval($GLOBALS['TSFE']->sys_language_content);
}
$query .= ' AND ' . $conf['languageField'] . ' IN (' . $sys_language_content . ')';
And $GLOBALS['TSFE']->sys_language_contentOL will be 1. So there will be no translation.
This is the config:
config {
sys_language_uid = 1
sys_language_mode = content_fallback; 0
sys_language_overlay = 1
}
With this config I expect a translation…
I feel like a newbie. Page translation layer/record was missing !!!
Related
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 have a problem with accessing content in a content object in TYPO3:
Running in TYPO3 8.7.11, I have a page with a Content Element "Image" and I've loaded a single image inside. I want to get an output like this:
<section class="foo" style="background-image:url('fileadmin/foo.png')">
<h2>[image title]</h2>
<p>[image description]</p>
</section>
I got the part with the image title and description working, but I cannot get the image filename for the background image running!
My current Typoscript looks like this:
(edited after Thomas answer, but still not running)
lib.teaser = CONTENT
lib.teaser {
table = tt_content
select.where = colPos = {$teaser_column}
languageField = sys_language_uid
renderObj = COA
renderObj {
# Attempt 1 (regarding the answer of Thomas Löffler)
# this doesn't work and result in an empty URL
#
# 10 {
# references {
# uid.data = uid
# table = tt_content
# fieldName = media
# }
#
# begin = 0
# maxItems = 1
#
# renderObj = IMG_RESOURCE
# renderObj {
# file.import.data = file:current:publicUrl
# }
# stdWrap.wrap = <section class="teaser" style="background-image:url('|');">
# }
# Attempt 2 (regarding the answer of Bernd Wilke πφ)
# this doesn't work and result in an empty URL
10 = FILES
10 {
references {
uid.data = uid
table = tt_content
fieldName = media
}
# a) did you mean that I want to replace
# my renderObj and use a TEXT object instead?
renderObj = TEXT
renderObj {
data = file:current:publicUrl
}
# b) ... or did you mean that I want to provide
# an IMG_RESOURCE and inside of that I want to
# provide a renderObj = TEXT?
#
# renderObj = IMG_RESOURCE
# renderObj {
# listNum = 0
# override.field = media
# renderObj = TEXT
# renderObj.data = file:current:publicUrl
# }
stdWrap.wrap = <section class="teaser" style="background-image:url('|');">
}
20 = TEXT
20.field = header
20.wrap = <h2 class="hide-text">|</h2>
30 = TEXT
30.field = bodytext
30.wrap = <p>|</p>
90 = TEXT
90.value = </section>
}
}
# ...
# edit: added after Thomas answer below
page {
10 = FLUIDTEMPLATE
10 {
format = html
file = {$root}/Templates/{$template}/Layouts/{$main_layout}.html
layoutRootPath = {$root}/Templates/{$template}/Layouts
partialRootPath = {$root}/Templates/{$template}/Partials
variables {
teaser < lib.teaser
# ... some other variables ...
}
# load templates for sections, otherwise Typo3 won't find your sections
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = {$root}/Templates/{$template}/Templates/Main.html
}
}
}
Currently resulting in this HTML code:
<section class="teaser" style="background-image:url('');">
<h2 class="hide-text">Get our latest products:</h2>
<p></p>
</section>
You use fluid_styled_content, don't you? Why not using FLUIDTEMPLATE and DataProcessing? There you get all the content data in a nice array and you are able to build your HTML like you want.
See https://usetypo3.com/custom-fsc-element.html for a small start.
Here the documentation for DataProcessing: https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/ContentObjects/Fluidtemplate/#dataprocessing
I can't try it but I would do it like this:
10 = FILES
10 {
references {
uid.data = uid
table = tt_content
fieldName = media
}
begin = 0
maxItems = 1
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
}
stdWrap.wrap = <section class="teaser" style="background-image:url('|');">
}
Example: https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/ContentObjects/Files/Index.html#usage-with-references
you have all the parts together, you just mixed them up.
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
listNum = 0
override.field = media
file.treatIdAsReference = 1
}
IMG_RESOURCE would be the correct object, but you do not build it up correctly:
file.import.data = file:current:publicUrl: where the filename is expected you provide the full path to the image. Wait!? 'the full path to the image'? wasn't it what you want to achive?
renderObj = TEXT
renderObj.data = file:current:publicUrl
If you use 'treatIdAsReference = 1' you need to provide an UId (of a sys_file) and no name
10 = FILES
10 {
references {
// this line should not be neccessary as the current context identifies the record
#uid.data = uid
table = tt_content
fieldName = media
}
// we only can handle one image:
maxItems = 1
// if we want no processing of the image:
renderObj = TEXT
renderObj {
data = file:current:publicUrl
}
// maybe a processing is necessary
// (always deliver smallest image possible)
#renderObj = IMG_RESOURCE
#renderObj {
# file {
# import.data = file:current:uid
# treatIdAsReference = 1
# width = 500c
# height = 200c
# }
#}
stdWrap.wrap = <section class="teaser" style="background-image:url('|');">
}
If this does not work you have a general problem extracting the files from your tt_content elements.
Maybe your fieldname is not media?
Inspect your database:
SELECT fieldname
FROM sys_file_reference
WHERE tablenames = 'tt_content'
AND uid_foreign = <tt_content_record-uid>
I just inspected one installation of mine and found: the fieldname is assets.
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
}
}
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