smichaelsen / settings
用户友好的配置模块,适用于编辑器
2.0.0
2017-08-15 12:09 UTC
Requires
- typo3/cms: ^7.6 || ^8.6
Requires (Dev)
- phpunit/phpunit: 5.6.*
- squizlabs/php_codesniffer: *
Replaces
- settings: 2.0.0
- typo3-ter/settings: 2.0.0
README
因为你没有足够的TYPO3配置位置,对吧?
它做什么
settings提供了一个新的后端模块,其中扩展可以提供配置选项。为什么?自从我缺少一个让编辑器(非管理员)可以进行全局配置的地方以来。
如何使用
定义字段
使用TCA语法定义你的字段,并将其添加到表tx_settings_form
中。
示例(在Configuration/TCA/Overrides/tx_settings_form.php
中)
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$GLOBALS['TCA']['tx_settings_form']['columns'] = array_merge(
$GLOBALS['TCA']['tx_settings_form']['columns'],
[
'tx_myext_myfield' => [
'label' => 'My field',
'config' => [
'type' => 'input',
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tx_settings_form',
'tx_myext_myfield'
);
读取配置
1. TypoScript
所有配置的值都以TypoScript常量的形式在plugin.tx_settings
中可用。
2. Fluid ViewHelper
{namespace s=Smichaelsen\Settings\ViewHelpers}
{s:getValue(name:'tx_myext_myfield')} or <s:getValue name="tx_myext_myfield"/>
以及加载FAL资源
<s:loadFalResources field="tx_myext_logo" as="logos">
<f:image image="{logos.0}"/>
</s:loadFalResources>
3. PHP
您还可以通过PHP访问这些值。
$configurationService = GeneralUtility::makeInstance(\Smichaelsen\Settings\Service\ConfigurationService::class);
$allConfiguration = $configurationService->getAllConfiguration($GLOBALS['TSFE']->rootLine[0]['uid']);
已知问题
内联字段目前无法使用,包括FAL文件上传字段。