【问题标题】:How to make an extension configurable through extension manager (TYPO3)如何通过扩展管理器 (TYPO3) 使扩展可配置
【发布时间】:2019-11-26 18:26:15
【问题描述】:

我目前正在开发自己的 TYPO3 扩展程序(在 v 9.5.11 中),并且我想对我的扩展程序的一些设置进行自定义。当我转到管理工具-->设置-->扩展配置-->配置扩展时,我已经可以更改这些设置了。

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

我在哪里实现上述功能?

【问题讨论】:

  • 扩展配置已从扩展管理器(TYPO3 7 和 8)移动到您已经写过的地方。管理工具-->设置-->扩展配置-->配置扩展
  • 哦,好吧。所以没有办法将漂亮的设置轮到您的扩展管理器中?因为仍然有完全相同的空间用于配置、下载、删除等。
  • 扩展管理器中的配置轮已随 TYPO3 9.5 消失。只有编写自己的 TYPO3 扩展程序才能将其重新带回来。

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


【解决方案1】:

您只需在文件ext_conf_template.txt 中定义所需的设置,该文件需要存储在扩展程序的根级别。

official TYPO3 documentation 包含详细说明。

【讨论】:

    【解决方案2】:

    就像迈克尔说的,你需要把所有设置都放到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
    

    这是我在任何我想要的控制器中使用设置的方法:

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

    这是它的外观:

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      相关资源
      最近更新 更多