定制 oliverkroener/ok-prive-consent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

oliverkroener/ok-prive-consent

Composer 安装命令:

composer require oliverkroener/ok-prive-consent

包简介

Provides a backend module to manage privacy cookie consent scripts for Prive Cookie Consent.

README 文档

README

TYPO3 14 PHP 8.2+ License: GPL v2+ Version

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 before </body> by a PSR-14 event listener (no TypoScript or template changes required)
  • 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 14.3 LTS
  • PHP >= 8.2 (8.2–8.5)

Installation

Composer (recommended)

composer require oliverkroener/ok-prive-consent

Extension Manager

Download or upload the extension and activate it via Admin Tools > Extensions.

No site set required

The consent banner renders automatically on every frontend page once the extension is installed -- it is injected by a PSR-14 event listener registered through the extension's Services.yaml. No site set, TypoScript, or template change is needed.

A site set named oliverkroener/ok-prive-consent is still shipped (so existing site configurations that reference it under dependencies keep working), but it is now a no-op and entirely optional.

Usage

  1. Navigate to Web > Prive Consent in the TYPO3 backend
  2. Select a page in the page tree (the module resolves the site root automatically)
  3. Toggle Enable Prive script to activate/deactivate the banner
  4. Paste the JavaScript snippet from your Prive dashboard
  5. 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 once installed -- the banner is injected by the event listener with no further configuration. 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 --> AfterCacheableContentIsGeneratedEvent
                  |
             InjectBannerScript (listener) --> DatabaseService --> sys_template table
                  |                                  |
          inject before </body>              SiteFinder (TYPO3 core)
Component Path Description
ConsentController Classes/Controller/Backend/ PSR-7 controller (#[AsController]) with indexAction and saveAction
InjectBannerScript Classes/EventListener/ PSR-14 listener on AfterCacheableContentIsGeneratedEvent; splices the banner markup before </body>
DatabaseService Classes/Service/ Resolves the site and builds the banner markup via getBannerMarkup(ServerRequestInterface)
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 + autoconfigure (the event listener is auto-registered via #[AsEventListener])
Site set Configuration/Sets/OkPriveConsent/ config.yaml + no-op setup.typoscript; kept only so existing site-config references stay valid
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

The fields are declared in ext_tables.sql and read/written exclusively via QueryBuilder from the backend module (there is no TCA definition). Field names retain the original ok_prive_cookie_consent prefix for backward compatibility with existing data.

Frontend rendering order

The listener injects the markup before </body> in this order to ensure correct DOM timing:

  1. CSS -- cookie button stylesheet loaded via <link> tag
  2. Cookie button -- <a> element with data-cc="c-settings" attribute
  3. Prive script -- the consent JavaScript snippet (so it can bind to the button already in DOM)

Injecting via a PSR-14 event listener (rather than a TypoScript page.footerData USER object) makes rendering independent of site-set load order: a theme set that re-declares page = PAGE after this extension can no longer discard the banner. The markup is part of the cacheable page content, so it is stored in the page cache.

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

Automated. Scaled. Done.

Web3 · Cloud · Automation

Technology is only valuable when it solves a real problem. For over 30 years I've been translating between business and tech — so your investment in digitalisation doesn't stall at proof-of-concept but delivers measurable results.

oliverkroener/ok-prive-consent 适用场景与选型建议

oliverkroener/ok-prive-consent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「typo3」 「privacy」 「cookie-consent」 「gdpr」 「typo3-extension」 「consent-management」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 oliverkroener/ok-prive-consent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 oliverkroener/ok-prive-consent 我们能提供哪些服务?
定制开发 / 二次开发

基于 oliverkroener/ok-prive-consent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 42
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 37
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-02-13