-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add information about accessing TypoScript (#464)
* 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 * Update AccessTypoScriptWithExtensions.rst Co-authored-by: Sybille Peters <[email protected]> Co-authored-by: Tom Warwick <[email protected]>
- Loading branch information
1 parent
15284f0
commit 50e4e74
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Documentation/UsingSetting/AccessTypoScriptWithExtensions.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 an extension | ||
================================= | ||
|
||
.. note:: | ||
|
||
This part is written for extension developers. | ||
|
||
This page explains how to access TypoScript settings in an extension. | ||
|
||
Extbase controllers | ||
=================== | ||
|
||
In Extbase controllers, :ref:`Flexform settings <t3coreapi:read-flexforms-extbase>` and TypoScript settings will be | ||
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"). | ||
|
||
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. Allowing you to | ||
access settings like this: | ||
|
||
.. code-block:: xml | ||
{settings.key1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters