From ae83ef17079f528297052ad7858f8cfe335d6610 Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Mon, 8 Dec 2025 10:39:01 +0100 Subject: [PATCH 1/2] [TASK] Accessing site settings in Extbase Releases: main, 13.4 --- .../AccessingSiteConfiguration.rst | 5 +-- .../ApiOverview/SiteHandling/SiteSettings.rst | 37 ++++++++++++++++++- .../_Settings/_ExampleController.php | 21 +++++++++++ .../_Settings/_ExampleControllerIndex.html | 1 + 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 Documentation/ApiOverview/SiteHandling/_Settings/_ExampleController.php create mode 100644 Documentation/ApiOverview/SiteHandling/_Settings/_ExampleControllerIndex.html diff --git a/Documentation/ApiOverview/SiteHandling/AccessingSiteConfiguration.rst b/Documentation/ApiOverview/SiteHandling/AccessingSiteConfiguration.rst index 4b15304d16..9d5f299355 100644 --- a/Documentation/ApiOverview/SiteHandling/AccessingSiteConfiguration.rst +++ b/Documentation/ApiOverview/SiteHandling/AccessingSiteConfiguration.rst @@ -10,9 +10,6 @@ PHP API: accessing site configuration .. contents:: :local: -Introduction -============ - The PHP API for sites comes in two parts: - Accessing the current, resolved site object @@ -27,6 +24,7 @@ current request but based on a page ID or a site identifier. Let us look at both cases in detail. +.. _sitehandling-php-api-access: Accessing the current site object ================================= @@ -114,6 +112,7 @@ API .. include:: /CodeSnippets/Manual/Entity/SiteLanguage.rst.txt +.. _sitehandling-sitesetting-object: The :php:`SiteSettings` object ============================== diff --git a/Documentation/ApiOverview/SiteHandling/SiteSettings.rst b/Documentation/ApiOverview/SiteHandling/SiteSettings.rst index c4f0d4edfb..bd871aba0d 100644 --- a/Documentation/ApiOverview/SiteHandling/SiteSettings.rst +++ b/Documentation/ApiOverview/SiteHandling/SiteSettings.rst @@ -6,6 +6,8 @@ Site settings ============= +.. contents:: Table of contents + .. versionadded:: 13.1 Site settings can receive a type, a default value and some documentation in :ref:`site settings definitions `. It is @@ -78,11 +80,42 @@ Add settings to the :file:`settings.yaml `: :yaml:`categoryPid`. -.. index:: Site handling; TypoScript access to settings .. _sitehandling-settings-access: +Accessing site settings +======================= + +In PHP you can access the :php-short:`\TYPO3\CMS\Core\Site\Entity\SiteSettings` +from the :php-short:`\TYPO3\CMS\Core\Site\Entity\Site` object via +`getSettings()`. (See +`Accessing the current site object `_). + +.. _sitehandling-settings-access-extbase-fluid: + +Site settings in Extbase Fluid plugins +-------------------------------------- + +At the time of writing site settings are not available in Extbase controllers or +admins unless they have been passed on to the plugin settings via TypoScript +or made available in the controller. + +To make the site settings available to all templates in your controller +you can override method `AbstractController::initializeView()` and assign +the site to the view: + +.. literalinclude:: _Settings/_ExampleController.php + :caption: EXT:myvendor/my-extension/Classes/Controller/ExampleController + +You can then use the variable `{site.settings}` to access the site settings: + +.. literalinclude:: _Settings/_ExampleControllerIndex.html + :caption: EXT:myvendor/my-extension/Resources/Private/Templates/Example/Index.html + +.. index:: Site handling; TypoScript access to settings +.. _sitehandling-settings-access-typoscript: + Accessing site settings in page TSconfig or TypoScript -====================================================== +------------------------------------------------------ .. code-block:: typoscript diff --git a/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleController.php b/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleController.php new file mode 100644 index 0000000000..9aa57b22c3 --- /dev/null +++ b/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleController.php @@ -0,0 +1,21 @@ +view->assignMultiple([ + 'site' => $this->request->getAttribute('site'), + ]); + } + public function indexAction(): ResponseInterface + { + // Variable '{site}' is automatically available + return $this->htmlResponse(); + } +} diff --git a/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleControllerIndex.html b/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleControllerIndex.html new file mode 100644 index 0000000000..aa5be8c5a0 --- /dev/null +++ b/Documentation/ApiOverview/SiteHandling/_Settings/_ExampleControllerIndex.html @@ -0,0 +1 @@ +{site.settings.mywebsite.example} From 2d21968c8528bb3aa4206917204b39e580b66351 Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Mon, 8 Dec 2025 12:20:16 +0100 Subject: [PATCH 2/2] Apply suggestion from @linawolf --- Documentation/ApiOverview/SiteHandling/SiteSettings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ApiOverview/SiteHandling/SiteSettings.rst b/Documentation/ApiOverview/SiteHandling/SiteSettings.rst index bd871aba0d..b39d65641d 100644 --- a/Documentation/ApiOverview/SiteHandling/SiteSettings.rst +++ b/Documentation/ApiOverview/SiteHandling/SiteSettings.rst @@ -96,7 +96,7 @@ Site settings in Extbase Fluid plugins -------------------------------------- At the time of writing site settings are not available in Extbase controllers or -admins unless they have been passed on to the plugin settings via TypoScript +plugins unless they have been passed on to the plugin settings via TypoScript or made available in the controller. To make the site settings available to all templates in your controller