Reputation: 1309
I have the TYPO3 version 9.5.9 and added a backend module by using the following function:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'CBWebdesign.' . $_EXTKEY,
'tools', // Make module a submodule of 'admin'
'tools', // Submodule key
'top', // Position
array(
'Settings' => 'main',
),
array(
'access' => 'admin',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/icons/template/tx_ext_cbwebdesigntemplate.gif',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_cbwebdesigntemplate.xlf',
)
);
The new backend module appears in the menu under ADMIN TOOLS. But what do I have to do as the next step to see a page with settings fields for my module? Also I need to save them and use on front-end.
Sorry I have to specify my use case. I need to implement my settings page. I mean I have added module item to menu. But what is the best way to implement settings there ? Even to say exactly I want to show there my extension configuration from ext_conf_template file and also possibility to change settings there.
Upvotes: 1
Views: 849
Reputation: 750
[new answer based on updated question]
TYPO3 extension configuration that you specify in the template file ext_conf_template.txt
of your extension is stored in TYPO3's system-wide configuration typo3conf/LocalConfiguration.php
. These configuration are meant to be managed by the TYPO3 core and edited by backend users with administrative permissions only.
You find the function to change these settings in TYPO3 version 9.5.x under ADMIN TOOLS ➜ Settings ➜ Extension Configuration as shown in the following screenshot:
You can easily access these settings in your extension (for example in your controller) by using TYPO3's API. For example, to access the value foo
of the extension configuration:
use \TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use \TYPO3\CMS\Core\Utility\GeneralUtility;
...
$extensionKey = 'my_example';
$foo = GeneralUtility::makeInstance(ExtensionConfiguration::class)
->get($extensionKey, 'foo');
You could then pass the variable $foo
to the view (e.g. Fluid) to output it to the user (backend and/or frontend).
However, do not change the extension configuration in your own extension! This is not the purpose of the function or core class ExtensionConfiguration
. This type of configuration should only be maintained using TYPO3's Install Tool (as shown above).
See comments in file typo3/sysext/core/Classes/Configuration/ExtensionConfiguration.php
.
API to
get()
instance specific extension configuration options. [...]Note only
->get()
is official API and other public methods are low level core internal API that is usually only used by extension manager and install tool.
Also note that other methods in this class are marked as @internal
.
While accessing and processing (even displaying) the configuration is not a problem, you should not change it outside the Install Tool.
Depending on your specific use-case you possibly want to consider using FlexForms to let backend users (incl. editors) configure certain aspects of an extension — or TypoScript (if the configuration should be restricted for administrator users). For more complex scenarios you could create a dedicated database table (or extend an existing table such as be_users
) and store the configuration there.
Upvotes: 1
Reputation: 750
You have to implement a controller named Settings
and within the PHP class a method named mainAction()
. Let's assume your extension key reads my_example
, then the PHP namespace should be:
CBWebdesign\MyExample\Controller\Settings
...and the file/path of the controller file in your extension reads:
Classes/Controller/Settings.php
You also have to implement the view (for example using Fluid). The template file for the controller "Settings" and action "main" should be located in:
Classes/Resources/Private/Templates/Settings/Main.html
I suggest to review the source code of the existing system extensions that come with TYPO3 (for example the Extension Manager, located at typo3/sysext/extensionmanager/
). They all follow this paradigm.
Upvotes: 0