Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
=================================
Expand Down Expand Up @@ -114,6 +112,7 @@ API

.. include:: /CodeSnippets/Manual/Entity/SiteLanguage.rst.txt

.. _sitehandling-sitesetting-object:

The :php:`SiteSettings` object
==============================
Expand Down
37 changes: 35 additions & 2 deletions Documentation/ApiOverview/SiteHandling/SiteSettings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <site-sets-settings-definition>`. It is
Expand Down Expand Up @@ -78,11 +80,42 @@ Add settings to the :file:`settings.yaml <set-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 <https://docs.typo3.org/permalink/t3coreapi:sitehandling-php-api-access>`_).

.. _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
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
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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class ExampleController extends ActionController
{
public function initializeView(): void
{
$this->view->assignMultiple([
'site' => $this->request->getAttribute('site'),
]);
}
public function indexAction(): ResponseInterface
{
// Variable '{site}' is automatically available
return $this->htmlResponse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<f:debug>{site.settings.mywebsite.example}</f:debug>