From cdf5ec120877d51d02867ac7d6d8cf48f56b7c67 Mon Sep 17 00:00:00 2001 From: Sybille Peters Date: Tue, 5 Oct 2021 13:29:01 +0200 Subject: [PATCH 1/2] Add information about accessing TypoScript 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: #463 --- .../AccessTypoScriptWithExtensions.rst | 66 +++++++++++++++++++ Documentation/UsingSetting/Index.rst | 1 + 2 files changed, 67 insertions(+) create mode 100644 Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst diff --git a/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst b/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst new file mode 100644 index 000000000..a71e59bbc --- /dev/null +++ b/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst @@ -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 ` 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 ` + * :ref:`Extbase TypoScript reference ` + +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} diff --git a/Documentation/UsingSetting/Index.rst b/Documentation/UsingSetting/Index.rst index bc7652dd4..d5ccabae3 100644 --- a/Documentation/UsingSetting/Index.rst +++ b/Documentation/UsingSetting/Index.rst @@ -22,6 +22,7 @@ The TypoScript template configuration can be viewed and edited in the Entering AddTypoScriptWithExtensions + AccessTypoScriptWithExtensions Constants TheConstantEditor Register From adad7924c171caeb66b5b00e42b95fc85a1299c3 Mon Sep 17 00:00:00 2001 From: Tom Warwick Date: Tue, 12 Oct 2021 10:00:53 +0100 Subject: [PATCH 2/2] Update AccessTypoScriptWithExtensions.rst --- .../AccessTypoScriptWithExtensions.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst b/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst index a71e59bbc..d109eea09 100644 --- a/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst +++ b/Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst @@ -2,23 +2,23 @@ .. index:: TypoScript in extensions .. _extdev-access-typoscript: -=================================== -Access TypoScript in your extension -=================================== +================================= +Access TypoScript in an extension +================================= .. note:: This part is written for extension developers. -This page explains how to access TypoScript settings in extensions. +This page explains how to access TypoScript settings in an extension. Extbase controllers =================== In Extbase controllers, :ref:`Flexform settings ` 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`). +merged together. If settings exists in both, the Flexform takes precedence and overrides the TypoScript setting. +Note that both Flexform and TypoScript settings must use the convention of preceding the setting with +`settings.` (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"). @@ -58,7 +58,7 @@ In order to access TypoScript settings from an Extbase Controller. Fluid ===== -If Extbase controllers are used, :php:`$this->settings` is automatically passed to the Fluid template. Thus, you can +If Extbase controllers are used, :php:`$this->settings` is automatically passed to the Fluid template. Allowing you to access settings like this: .. code-block:: xml