问题
I create a header based on one image, one Main Header and one Sub Header.
The following fields/labels in page/edit/Metadata are renamed like that:
TCEFORM.pages.author.label.default = HeaderImageMainTitle
TCEFORM.pages.author_email.label.default = HeaderImageSubTitle
Now I get the content of the media/create new relation/image file and that works fine. But the values of the above two fields with former label 'author' and 'author_email' stay empty (the format tags are there, but no content):
lib.headerteaser = COA
lib.headerteaser.stdWrap.wrap = <div id="headerTeaser">|</div>
lib.headerteaser.10 = IMAGE
lib.headerteaser.10 {
file {
import.data = levelmedia:-1, slide
treatIdAsReference = 1
import.listNum = 0
}
wrap = |
}
lib.headerteaser.20 = TEXT
lib.headerteaser.20.data = levelfield : -1 , HeaderImageMainTitle, slide
lib.headerteaser.20.wrap = <div id="headerTeaserText"><h1>|</h1>
lib.headerteaser.30 = TEXT
lib.headerteaser.30.data = levelfield : -1 , HeaderImageSubTitle, slide
lib.headerteaser.30.wrap = <p>|</p></div>
The viewhelper in the template looks like that:
<f:cObject typoscriptObjectPath="lib.headerteaser" />
What do I miss? Studied google for hoooours!!
回答1:
I tested this code, works correctly (Typo3 7.6.0).
My tested Typoscript setup (without image):
lib.headerteaser = COA
lib.headerteaser.stdWrap.wrap = <div id="headerTeaser">|</div>
lib.headerteaser.20 = TEXT
lib.headerteaser.20.data = levelfield:-1, author, slide
lib.headerteaser.20.wrap = <div id="headerTeaserText"><h1>|</h1>
lib.headerteaser.30 = TEXT
lib.headerteaser.30.data = levelfield:-1, author_email, slide
lib.headerteaser.30.wrap = <p>|</p></div>
page = PAGE
page.10 < lib.headerteaser
Setup typo3conf/LocalConfiguration.php:
<?php
return [
...
'FE' => [
'addRootLineFields' => ',author,author_email',
],
...
];
Plus clear Typo3 cache.
回答2:
In .data attribute use field name, not field label:
lib.headerteaser.20.data = levelfield:-1, author, slide
lib.headerteaser.30.data = levelfield:-1, author_email, slide
And I think that You need update Typo3 configuration:
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = ',author,author_email';
来源:https://stackoverflow.com/questions/34755983/typo3-how-can-i-read-the-value-of-a-field-in-page-edit-tab-metadata