Configuration

There are several possibilities to make your extension configurable. From the various options described here each differs in:

  • the scope to what the configuration applies (extension, pages, plugin)
  • the access level required to make the change (editor, admin)

TypoScript and constants

You can define configuration options using TypoScript. These options can be changed via TypoScript constants and setup in the backend. The changes apply to the current page and all subpages.

Extension configuration

Extension configuration is defined in the file ext_conf_template.txt using TypoScript constant syntax.

The configuration options you define in this file can be changed in the backend Admin Tools > Settings > Extension Configuration and is stored in config/system/settings.php.

Use this file for general options that should be globally applied to the extension.

FlexForms

FlexForms can be configured in the backend by editors. With FlexForms you can configure each plugin or content element individually without adding extra fields to the tt_content table.

In Extbase plugins, settings made in the FlexForm of a plugin override settings made in the TypoScript configuration of that plugin.

Example

EXT:blog_example/Configuration/FlexForms/PluginSettings.xml
<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>Options</sheetTitle>
                <type>array</type>
                <el>
                    <settings.itemsPerPage>
                        <label>Max. number of items to display per page</label>
                        <config>
                            <type>number</type>
                            <size>2</size>
                            <default>3</default>
                        </config>
                    </settings.itemsPerPage>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>
Copied!

Access settings

The settings can be read using $this->settings in an Extbase controller action and via {settings} within Fluid.

Example: Access settings in an Extbase controller

Class T3docs\BlogExample\Controller\PostController
use Psr\Http\Message\ResponseInterface;

class PostController extends AbstractController
{
    public function displayRssListAction(): ResponseInterface
    {
        $defaultBlog = $this->settings['defaultBlog'] ?? 0;
        if ($defaultBlog > 0) {
            $blog = $this->blogRepository->findByUid((int)$defaultBlog);
        } else {
            $blog = $this->blogRepository->findAll()->getFirst();
        }
        $this->view->assign('blog', $blog);
        return $this->responseFactory->createResponse()
            ->withHeader('Content-Type', 'text/xml; charset=utf-8')
            ->withBody($this->streamFactory->createStream($this->view->render()));
    }
}
Copied!

YAML

Some extensions offer configuration in the format YAML, see YAML.

There is a YamlFileLoader which can be used to load YAML files.