Skip to content

Commit

Permalink
Add information about accessing TypoScript (#464)
Browse files Browse the repository at this point in the history
* 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 <sybille.peters@uni-oldenburg.de>
Co-authored-by: Tom Warwick <tom.warwick@typo3.org>
  • Loading branch information
3 people committed Oct 13, 2021
1 parent 15284f0 commit 50e4e74
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 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}
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 50e4e74

Please sign in to comment.