如何通过扩展管理器(TYPO3)使扩展可配置

时间:2019-11-26 18:26:15

标签: typo3 content-management-system typo3-9.x typo3-extensions

我目前正在开发自己的TYPO3扩展(在9.5.11版中),我想对扩展的某些设置进行自定义。当我转到“管理工具”->“设置”->“扩展名配置”->“配置扩展名”时,我已经可以更改这些设置。

但是,在早期版本的TYPO3(例如v7)中,也可以通过管理工具->扩展->“单击所需扩展名的设置轮”来配置扩展。(见图片)。

The Settings Wheel

我在哪里实现上述功能?

2 个答案:

答案 0 :(得分:5)

您只需在文件ext_conf_template.txt中定义所需的设置,该文件需要存储在扩展的根目录下。

official TYPO3 documentation包含详细说明。

答案 1 :(得分:1)

就像迈克尔所说,您需要将所有设置都放入ext_conf_template.txt

以下是我的扩展名“ slug”的示例,您也可以在GithubTYPO3 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

这是我在想要的任何控制器中使用settig的方式:

<?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'];
       }

}

这是它的外观: enter image description here