Skip to content

Commit

Permalink
task: Use path getText for local paths (TypoScript)
Browse files Browse the repository at this point in the history
Fixes: #271
  • Loading branch information
jonaseberle committed Jan 22, 2024
1 parent 1ea2ffe commit efbcc53
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
13 changes: 9 additions & 4 deletions Documentation/Configuration/Example/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This example configuration is based on the base TypoScript configuration
trackingObjects {
# extend the existing configuration for 'Matomo'
Matomo {
inject >
inject (
<script type="text/javascript">
var _paq = window._paq || [];
Expand All @@ -44,10 +45,14 @@ This example configuration is based on the base TypoScript configuration
# add my own custom tracking solution
# if you have a useful configuration and want to share, we would be happy if you did a pull request!
MyOwnTrackingPixel {
inject (
<div>Here be dragons <img src="https://via.placeholder.com/200x200?text=Tracking pixel..."></div>
<script>alert('oh la la!')</script>
)
inject = TEXT
inject {
insertData = 1
value = (
<div>Here be dragons <img src="/{path : EXT:my_ext/Resources/Public/Image/MyImage.png}"></div>
<script>alert('oh la la!')</script>
)
}
show {
# each element here represents one line of information in the consent popup
pixelphp {
Expand Down
12 changes: 8 additions & 4 deletions Documentation/Configuration/How-To/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ Cookieman allows to add external sources with the :ref:`inject <trackingObjects.
plugin.tx_cookieman.settings.trackingObjects {
Matomo {
inject (
<script src="https://your-domain.com/typo3conf/ext/your_sitepackage/Resources/Public/JavaScript/matomo-trackingcode.js"></script>
<script src="https://your-matomo-server.com/path/to/matomo.js" async defer></script>
)
inject = TEXT
inject {
insertData = 1
value (
<script src="/{path : EXT:your_sitepackage/Resources/Public/JavaScript/matomo-trackingcode.js}"></script>
<script src="https://your-matomo-server.com/path/to/matomo.js" async defer></script>
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ trackingObjects.‹tracking-object-key›.inject
.. rst-class:: dl-parameters

trackingObjects.‹tracking-object-key›.inject
:sep:`|` :aspect:`Data type:` :ref:`data-type-html-code`
:sep:`|` :aspect:`Data type:` :ref:`data-type-html-code` / :ref:`cObject <data-type-cobject>`
:sep:`|` :aspect:`Example:` <script src="/path/to/tracking-code.js"></script>
:sep:`|`

Expand All @@ -200,6 +200,13 @@ trackingObjects.‹tracking-object-key›.inject

You can either use inline script or link to an external file (useful if a HTTP header `Content-Security-Policy` is set).

If you need a local path from your `_assets` directory, let TYPO3 build it. We currently recommend using `TEXT`
with `insertData = 1` and the getText `{path : EXT:…}`. The preceding root path (`/`) is necessary for it to work on subpages.
See the example above.

It has shortcomings (see https://forge.typo3.org/issues/99203#change-507069).
For v13 we'll probably get the {asset : ...} getText (https://review.typo3.org/c/Packages/TYPO3.CMS/+/77018).

.. _trackingObjects.‹tracking-object-key›.show:

trackingObjects.‹tracking-object-key›.show
Expand Down

0 comments on commit efbcc53

Please sign in to comment.