Skip to content

Commit

Permalink
Add information about accessing TypoScript
Browse files Browse the repository at this point in the history
The information about accessing TypoScript is missing in
extensions. This patch adds the information for Extbase
controllers (and refers to existing documentation).

Information about how to access TypoScript outside of Extbase
controllers can be added in future patches.

Related: TYPO3-Documentation#463
  • Loading branch information
sypets committed Oct 5, 2021
1 parent b510a65 commit cdf5ec1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. include:: /Includes.rst.txt
.. index:: TypoScript in extensions
.. _extdev-access-typoscript:

===================================
Access TypoScript in your extension
===================================

.. note::

This part is written for extension developers.

This page explains how to access TypoScript settings in extensions.

Extbase controllers
===================

In Extbase controllers, :ref:`Flexform settings <t3coreapi:read-flexforms-extbase>` and TypoScript settings will be
merged together. If a settings exists in both, the Flexform takes precedence (and overrides the TypoScript setting).
Keep in mind that both Flexform and TypoScript settings must use the convention of preceding the setting with
`setting.` (e.g. `settings.threshold`).

Extbase offers some advantages: Some things work automatically out-of-the-box. However, you must stick to the
Extbase conventions ("conventions over configuration").

In order to access TypoScript settings from an Extbase Controller.

.. rst-class:: bignums-xxl

#. Use the convention of defining your TypoScript settings in :ts:`settings`

.. code-block:: ts
plugin.tx_myextension {
view {
# view settings
}
settings {
key1 = value1
key2 = value2
}
}
#. Access them via :php:`$this->settings`

For example, in your controller:

.. code-block:: php
$myvalue1 = $this->settings['key1'] ?? 'default';
.. seealso::

* :ref:`settings in Extbase extensions <t3extbasebook:configuration>`
* :ref:`Extbase TypoScript reference <t3extbasebook:typoscript_configuration>`

Fluid
=====

If Extbase controllers are used, :php:`$this->settings` is automatically passed to the Fluid template. Thus, you can
access settings like this:

.. code-block:: xml
{settings.key1}
1 change: 1 addition & 0 deletions Documentation/UsingSetting/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The TypoScript template configuration can be viewed and edited in the

Entering
AddTypoScriptWithExtensions
AccessTypoScriptWithExtensions
Constants
TheConstantEditor
Register
Expand Down

0 comments on commit cdf5ec1

Please sign in to comment.