Skip to content

Commit ba676d3

Browse files
[FEATURE] Introduce Fluid page title ViewHelper (#6004)
* [FEATURE] Introduce Fluid page title ViewHelper Resolves: TYPO3-Documentation/Changelog-To-Doc#1308 Releases: main * [FEATURE] Introduce Fluid page title ViewHelper Resolves: TYPO3-Documentation/Changelog-To-Doc#1308 Releases: main * [FEATURE] Introduce Fluid page title ViewHelper Resolves: TYPO3-Documentation/Changelog-To-Doc#1308 Releases: main * Update PageTitleApi.rst * Update PageTitleApi.rst --------- Co-authored-by: Garvin Hicking <[email protected]>
1 parent 93fd6fd commit ba676d3

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

Documentation/ApiOverview/Seo/PageTitleApi.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ providers if a title is given by the provider.
1717
Besides the providers shipped by the Core, you can add own providers. An
1818
integrator can define the priority of the providers for his project.
1919

20+
.. versionadded:: 14.0
21+
The page title can also be set via the `Page.title ViewHelper
22+
<f:page.title> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-page-title>`_.
23+
2024
.. seealso::
2125

2226
The page title is further influenced by :ref:`t3tsref:setup-config-pagetitle`
@@ -48,6 +52,22 @@ page, this provider will provide that title.
4852
If you have not installed the SEO system
4953
extension, the field and provider are not available.
5054

55+
.. _page-title-provider-record-title:
56+
57+
RecordTitleProvider
58+
-------------------
59+
60+
.. versionadded:: 14.0
61+
62+
The fallback provider with the lowest priority is the
63+
:php:`\TYPO3\CMS\Core\PageTitle\RecordTitleProvider`. It has the identifier
64+
`recordTitle`.
65+
66+
This provider can be used by third-party extensions to set the page title.
67+
68+
.. literalinclude:: _PageTitleProvider/_RecordTitleProviderUsage.php
69+
:caption: my_extension/Classes/Controller/ItemController.php
70+
5171
.. _page-title-provider-record:
5272

5373
RecordPageTitleProvider
@@ -72,6 +92,10 @@ the page record will not be the correct title. To make sure to display the
7292
correct page title, you have to create your own page title provider. It is
7393
quite easy to create one.
7494

95+
.. versionadded:: 14.0
96+
In many use cases, the provider `RecordTitleProvider`
97+
can be used instead of writing a custom page title provider.
98+
7599
.. _page-title-provider-custom-example:
76100

77101
Example: Set the page title from your extension's controller
@@ -154,8 +178,9 @@ The sorting of the providers is based on the :typoscript:`before` and
154178
specific other provider, just set that provider in the :typoscript:`before`,
155179
do the same with :typoscript:`after`.
156180

157-
If you have installed the system extension SEO, you will also get a second
158-
provider. The configuration will be:
181+
For example, if you want the :php-short:`\TYPO3\CMS\Core\PageTitle\RecordTitleProvider`
182+
to take priority over the :php-short:`\TYPO3\CMS\Seo\PageTitle\SeoTitlePageTitleProvider`
183+
you can change the order via TypoScript:
159184

160185
.. literalinclude:: _PageTitleProvider/_pageTitleProviders.typoscript
161186

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MyVendor\MyExtension\Controller;
6+
7+
use MyVendor\MyExtension\Domain\Model\Item;
8+
use Psr\Http\Message\ResponseInterface;
9+
use TYPO3\CMS\Core\PageTitle\RecordTitleProvider;
10+
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
11+
12+
final class ItemController extends ActionController
13+
{
14+
public function __construct(
15+
private readonly RecordTitleProvider $recordTitleProvider,
16+
) {}
17+
18+
public function showAction(Item $item): ResponseInterface
19+
{
20+
$this->recordTitleProvider->setTitle($item->getTitle());
21+
$this->view->assign('item', $item);
22+
return $this->htmlResponse();
23+
}
24+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
config.pageTitleProviders {
2-
record {
3-
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
2+
record.provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
3+
recordTitle {
4+
provider = TYPO3\CMS\Core\PageTitle\RecordTitleProvider
5+
before = record
46
}
57
}
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
config.pageTitleProviders {
2-
record {
3-
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
4-
}
5-
seo {
6-
provider = TYPO3\CMS\Seo\PageTitle\SeoTitlePageTitleProvider
7-
before = record
2+
recordTitle {
3+
before = seo
84
}
95
}

0 commit comments

Comments
 (0)