Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information about accessing TypoScript #464

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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