就像迈克尔说的,你需要把所有设置都放到ext_conf_template.txt
这是我的扩展“slug”的示例,您也可以在Github 或TYPO3 repository 中找到它。它包含一些特殊的字段,甚至是翻译。
# Settings
###########################
# cat=defaults; type=options[10,20,30,40,50,60,70,80,90,100,150,200,300,400,500]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.maxentries
defaultMaxEntries = 20
# cat=defaults; type=options[crdate,tstamp,title,slug,sys_language_uid,is_siteroot,doktype]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.orderby
defaultOrderBy = crdate
# cat=defaults; type=options[DESC,ASC]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.order
defaultOrder = DESC
# cat=defaults; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:default.recordInfoEnabled
recordInfoEnabled = 1
# cat=tree; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.enabled
treeEnabled = 1
# cat=tree; type=options[1,2,3,4,5,6,7,8,9,10]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.depth
treeDefaultDepth = 3
# cat=tree; type=string; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:tree.root
treeDefaultRoot =
# cat=custom records; type=boolean; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.enabled
recordEnabled = 0
# cat=custom records; type=options[10,20,30,40,50,60,70,80,90,100,150,200,300,400,500]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.maxentries
recordMaxEntries = 10
# cat=custom records; type=options[crdate,title,path_segment,sys_language_uid]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.orderby
recordOrderBy = crdate
# cat=custom records; type=options[DESC,ASC]; label=LLL:EXT:slug/Resources/Private/Language/locallang_be.xlf:record.order
recordOrder = DESC
这是我在任何我想要的控制器中使用设置的方法:
<?php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
class ExtensionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function __construct() {
$this->backendConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('slug');
}
public function myRandomFunction(){
$variable = $this->backendConfiguration['recordMaxEntries'];
}
}
这是它的外观: