oliverkroener / ok-prive-consent
Provides a backend module to manage privacy cookie consent scripts for Prive Cookie Consent.
Package info
github.com/oliverkroener/ok_prive_consent
Type:typo3-cms-extension
pkg:composer/oliverkroener/ok-prive-consent
Requires
- php: >=8.1
- typo3/cms-backend: ^12.4 || ^13.4
- typo3/cms-core: ^12.4 || ^13.4
README
TYPO3 backend module for managing Prive Cookie Consent banner scripts.
Features
- Backend module under Web > Prive Consent for editing consent scripts
- Enable/disable toggle to activate or deactivate the banner without removing the script
- Multi-site support -- automatically resolves the correct site root per TYPO3 site configuration
- Unsaved changes protection -- warns before navigating away with unsaved modifications (with "save and close" support)
- Automatic frontend rendering -- script and cookie settings button injected via TypoScript
page.footerData - Cache flush on save -- frontend page cache is cleared automatically after saving
- Cookie settings button -- fixed-position floating button with SVG cookie icon for visitors to reopen consent dialog
Requirements
- TYPO3 12.4 LTS or 13.4 LTS
- PHP >= 8.1
Installation
Composer (recommended)
composer req oliverkroener/ok-prive-consent
Extension Manager
Download or upload the extension and activate it via Admin Tools > Extensions.
Include static TypoScript
- Open the Template module in the TYPO3 backend
- Select the root page of your site
- Edit the template record (Info/Modify > Edit the whole template record)
- Under the Includes tab, add [kroener.DIGITAL] Prive Consent
- Clear all caches
Usage
- Navigate to Web > Prive Consent in the TYPO3 backend
- Select a page in the page tree (the module resolves the site root automatically)
- Toggle Enable Prive script to activate/deactivate the banner
- Paste the JavaScript snippet from your Prive dashboard
- Click Save
The consent script and a cookie settings button are rendered automatically in the page footer on all frontend pages.
Configuration
The extension works out of the box after including the static TypoScript template. To customise the cookie settings button, override the styles from Resources/Public/Css/prive-cookie-button.css in your site package.
Brand colours: primary #f05722, secondary #0fa8dd.
Architecture
TYPO3 Backend --> ConsentController --> sys_template table
|
ModuleTemplateFactory,
SiteFinder, ConnectionPool
(TYPO3 core)
Frontend --> TypoScript USER object --> DatabaseService --> sys_template table
|
SiteFinder (TYPO3 core)
| Component | Path | Description |
|---|---|---|
ConsentController |
Classes/Controller/Backend/ |
PSR-7 controller (#[AsController]) with indexAction and saveAction |
DatabaseService |
Classes/Service/ |
Renders banner script for frontend output as a TypoScript USER function |
| Module registration | Configuration/Backend/Modules.php |
Declarative backend module under Web menu with page tree navigation |
| Icon registration | Configuration/Icons.php |
SVG module icon via SvgIconProvider |
| JavaScript modules | Configuration/JavaScriptModules.php |
ES6 module mapping for @oliverkroener/ok-prive-consent/ |
| Dependency injection | Configuration/Services.yaml |
Autowiring enabled; DatabaseService marked public for TypoScript USER |
| TCA override | Configuration/TCA/Overrides/sys_template.php |
Registers static TypoScript template |
| TypoScript | Configuration/TypoScript/setup.typoscript |
Defines lib.priveScript USER object and page.footerData |
| Fluid templates | Resources/Private/Templates/Backend/Consent/ |
Index.html -- form with three states (no page, no site, edit) |
| FormDirtyCheck | Resources/Public/JavaScript/backend/ |
ES6 module for unsaved changes detection with ConsumerScope integration |
| Localisation | Resources/Private/Language/ |
English (locallang.xlf) and German (de.locallang.xlf) |
Database fields (on sys_template)
| Field | Type | Description |
|---|---|---|
tx_ok_prive_cookie_consent_banner_script |
text | The JavaScript consent snippet |
tx_ok_prive_cookie_consent_banner_enabled |
boolean | Enable/disable toggle |
Frontend rendering order
The page.footerData output follows this order to ensure correct DOM timing:
- CSS -- cookie button stylesheet loaded via
<link>tag - Cookie button --
<a>element withdata-cc="c-settings"attribute - Prive script -- the consent JavaScript snippet (so it can bind to the button already in DOM)
Documentation
Full documentation is available in the Documentation/ directory. Generate rendered docs locally with:
make docs
This uses the official TYPO3 Documentation rendering container.
License
GPL-2.0-or-later
Author
Oliver Kroener -- oliver-kroener.de -- ok@oliver-kroener.de