Skip to content

Commit 190c285

Browse files
authored
[TASK] Refactor page title provider page (#6000)
In preparation for TYPO3-Documentation/Changelog-To-Doc#1308. * Add anchors * move example snippets in one folder Releases: main, 13.4
1 parent 281712b commit 190c285

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

Documentation/ApiOverview/Seo/PageTitleApi.rst

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Based on the priority of the providers, the
1515
providers if a title is given by the provider. It will start with the highest
1616
priority and will end with the lowest priority.
1717

18-
By default, the Core ships two providers. If you have installed the :doc:`system
19-
extension SEO <ext_seo:Index>`, the provider with the (by default) highest
18+
By default, the Core ships two providers. If you have installed
19+
:composer:`typo3/cms-seo`, the provider with the (by default) highest
2020
priority will be the :php:`\TYPO3\CMS\Seo\PageTitle\SeoTitlePageTitleProvider`.
2121
When an editor has set a value for the SEO title in the page properties of the
2222
page, this provider will provide that title to the
@@ -40,6 +40,8 @@ integrator can define the priority of the providers for his project.
4040

4141
.. index:: PageTitle; Custom PageTitleProvider
4242

43+
.. _page-title-provider-custom:
44+
4345
Create your own page title provider
4446
===================================
4547

@@ -49,6 +51,8 @@ the page record will not be the correct title. To make sure to display the
4951
correct page title, you have to create your own page title provider. It is
5052
quite easy to create one.
5153

54+
.. _page-title-provider-custom-example:
55+
5256
Example: Set the page title from your extension's controller
5357
------------------------------------------------------------
5458

@@ -57,27 +61,29 @@ First, create a PHP class in your extension that implements the
5761
extending :php:`\TYPO3\CMS\Core\PageTitle\AbstractPageTitleProvider`. Within
5862
this method you can create your own logic to define the correct title.
5963

60-
.. literalinclude:: _ExampleSetInController/_MyOwnPageTitleProvider.php
64+
.. literalinclude:: _PageTitleProvider/_ExampleSetInController/_MyOwnPageTitleProvider.php
6165
:caption: EXT:my_extension/Classes/PageTitle/MyOwnPageTitleProvider.php
6266

6367
Usage example in an :ref:`Extbase <extbase>` controller:
6468

65-
.. literalinclude:: _ExampleSetInController/_SomeController.php
69+
.. literalinclude:: _PageTitleProvider/_ExampleSetInController/_SomeController.php
6670
:caption: EXT:my_extension/Classes/Controller/SomeController.php
6771

6872
Configure the new page title provider in your TypoScript setup:
6973

70-
.. literalinclude:: _ExampleSetInController/_setup.typoscript
74+
.. literalinclude:: _PageTitleProvider/_ExampleSetInController/_setup.typoscript
7175
:language: typoscript
7276
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
7377

78+
.. _page-title-provider-custom-site-config:
79+
7480
Example: Use values from the site configuration in the page title
7581
-----------------------------------------------------------------
7682

7783
If you want to use data from the :ref:`site configuration <sitehandling>`, for
7884
example the site title, you can implement a page title provider as follows:
7985

80-
.. literalinclude:: _ExampleWebsiteTitle/_WebsiteTitleProvider.php
86+
.. literalinclude:: _PageTitleProvider/_WebsiteTitleProvider.php
8187
:caption: EXT:my_sitepackage/Classes/PageTitle/WebsiteTitleProvider.php
8288

8389
.. versionchanged:: 13.0
@@ -93,7 +99,7 @@ and PHP Cache`.
9399

94100
Configure the new page title provider to be used in your TypoScript setup:
95101

96-
.. literalinclude:: _ExampleWebsiteTitle/_setup.typoscript
102+
.. literalinclude:: _PageTitleProvider/_website.typoscript
97103
:language: typoscript
98104
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
99105

@@ -109,22 +115,18 @@ you can change this by loading your custom provider before `seo`.
109115
.. index:: PageTitle; Priority
110116

111117
.. _define-the-priority-of-pagetitleproviders:
118+
112119
Define the priority of PageTitleProviders
113120
=========================================
114121

115122
The priority of the providers is set by the TypoScript property
116-
:typoscript:`config.pageTitleProviders`. This way an integrator is able to set
117-
the priorities for his project and can even have conditions in place.
123+
`config.pageTitleProviders <https://docs.typo3.org/permalink/t3tsref:confval-config-pagetitleproviders>`_.
124+
This way an integrator is able to set
125+
the priorities for their project and can even have conditions in place.
118126

119127
By default, the Core has the following setup:
120128

121-
.. code-block:: typoscript
122-
123-
config.pageTitleProviders {
124-
record {
125-
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
126-
}
127-
}
129+
.. literalinclude:: _PageTitleProvider/_core.typoscript
128130

129131
The sorting of the providers is based on the :typoscript:`before` and
130132
:typoscript:`after` parameters. If you want a provider to be handled before a
@@ -134,17 +136,7 @@ do the same with :typoscript:`after`.
134136
If you have installed the system extension SEO, you will also get a second
135137
provider. The configuration will be:
136138

137-
.. code-block:: typoscript
138-
139-
config.pageTitleProviders {
140-
record {
141-
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
142-
}
143-
seo {
144-
provider = TYPO3\CMS\Seo\PageTitle\SeoTitlePageTitleProvider
145-
before = record
146-
}
147-
}
139+
.. literalinclude:: _PageTitleProvider/_pageTitleProviders.typoscript
148140

149141
First the :php:`SeoTitlePageTitleProvider` (because it will be handled before
150142
:typoscript:`record`) and, if this providers did not provide a title, the

Documentation/ApiOverview/Seo/_ExampleSetInController/_MyOwnPageTitleProvider.php renamed to Documentation/ApiOverview/Seo/_PageTitleProvider/_ExampleSetInController/_MyOwnPageTitleProvider.php

File renamed without changes.

Documentation/ApiOverview/Seo/_ExampleSetInController/_SomeController.php renamed to Documentation/ApiOverview/Seo/_PageTitleProvider/_ExampleSetInController/_SomeController.php

File renamed without changes.

Documentation/ApiOverview/Seo/_ExampleSetInController/_setup.typoscript renamed to Documentation/ApiOverview/Seo/_PageTitleProvider/_ExampleSetInController/_setup.typoscript

File renamed without changes.

Documentation/ApiOverview/Seo/_ExampleWebsiteTitle/_WebsiteTitleProvider.php renamed to Documentation/ApiOverview/Seo/_PageTitleProvider/_WebsiteTitleProvider.php

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
config.pageTitleProviders {
2+
record {
3+
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
4+
}
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
config.pageTitleProviders {
2+
record {
3+
provider = TYPO3\CMS\Core\PageTitle\RecordPageTitleProvider
4+
}
5+
seo {
6+
provider = TYPO3\CMS\Seo\PageTitle\SeoTitlePageTitleProvider
7+
before = record
8+
}
9+
}

Documentation/ApiOverview/Seo/_ExampleWebsiteTitle/_setup.typoscript renamed to Documentation/ApiOverview/Seo/_PageTitleProvider/_website.typoscript

File renamed without changes.

0 commit comments

Comments
 (0)