Skip to content

Commit 2a314f7

Browse files
committed
[FEATURE] Introduce HeaderData and FooterData ViewHelpers
References: TYPO3-Documentation/Changelog-To-Doc#1301 Releases: main
1 parent 5db918f commit 2a314f7

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

Documentation/Global/Page/FooterData.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,30 @@
1212
Page.footerData ViewHelper `<f:page.footerData>`
1313
================================================
1414

15+
.. versionadded:: 14.0
16+
17+
The `<f:page.footerData>` ViewHelper allows injecting arbitrary content right
18+
before the closing :php:`</body>` tag of a rendered page.
19+
20+
The ViewHelper internally uses the `PageRenderer API <https://docs.typo3.org/permalink/t3coreapi:assets-page-renderer>`_
21+
and is useful when ViewHelpers like
22+
`<f:asset.css> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-css>`_ or
23+
`<f:asset.script> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-script>`_
24+
do not support all required attributes or use cases
25+
(for example tracking code or inline JavaScript).
26+
27+
.. warning::
28+
29+
The ViewHelper outputs given content as is. Possible user supplied input for
30+
the ViewHelpers **must manually be escaped** in order to prevent a
31+
`Cross-site scripting (XSS) <https://docs.typo3.org/permalink/t3coreapi:security-xss>`_
32+
vulnerability.
33+
1534
.. typo3:viewhelper:: page.footerData
1635
:source: ../../Global.json
36+
:display: tags,gitHubLink
37+
38+
.. rubric:: Example usage
39+
40+
.. literalinclude:: _codesnippets/_FooterData.html
41+
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. This reStructured text file has been automatically generated, do not change.
2-
.. Source: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid/Classes/ViewHelpers/Page/HeaderDataViewHelper.php
3-
4-
:edit-on-github-link: https://github.com/TYPO3/typo3/edit/main/typo3/sysext/fluid/Classes/ViewHelpers/Page/HeaderDataViewHelper.php
51
:navigation-title: page.headerData
62

73
.. include:: /Includes.rst.txt
@@ -12,5 +8,30 @@
128
Page.headerData ViewHelper `<f:page.headerData>`
139
================================================
1410

11+
.. versionadded:: 14.0
12+
13+
The `<f:page.headerData>` ViewHelper allows injecting arbitrary content into
14+
the HTML :php:`<head>` of a rendered page.
15+
16+
The ViewHelper internally uses the `PageRenderer API <https://docs.typo3.org/permalink/t3coreapi:assets-page-renderer>`_
17+
and is useful when ViewHelpers like
18+
`<f:asset.css> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-css>`_ or
19+
`<f:asset.script> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-script>`_
20+
do not support all required attributes or use cases
21+
(for example `dns-prefetch`, `preconnect`, tracking scripts, or inline
22+
JavaScript).
23+
24+
.. warning::
25+
26+
The ViewHelper outputs given content as is. Possible user supplied input for
27+
the ViewHelpers **must manually be escaped** in order to prevent a
28+
`Cross-site scripting (XSS) <https://docs.typo3.org/permalink/t3coreapi:security-xss>`_
29+
vulnerability.
30+
1531
.. typo3:viewhelper:: page.headerData
1632
:source: ../../Global.json
33+
:display: tags,gitHubLink
34+
35+
.. rubric:: Example usage
36+
37+
.. literalinclude:: _codesnippets/_HeaderData.html
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<f:page.footerData>
2+
<script>
3+
var _paq = window._paq = window._paq || [];
4+
_paq.push(['trackPageView']);
5+
_paq.push(['enableLinkTracking']);
6+
(function() {
7+
var u = "https://your-matomo-domain.example.com/";
8+
_paq.push(['setTrackerUrl', u + 'matomo.php']);
9+
_paq.push(['setSiteId', '1']);
10+
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
11+
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
12+
})();
13+
</script>
14+
</f:page.footerData>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<f:page.headerData>
2+
<link rel="preload" href="/fonts/myfont.woff2" as="font" type="font/woff2" crossorigin="anonymous">
3+
<link rel="dns-prefetch" href="//example-cdn.com">
4+
<link rel="preconnect" href="https://example-cdn.com">
5+
</f:page.headerData>

0 commit comments

Comments
 (0)