PHPackages                             hofff/contao-consent-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hofff/contao-consent-bridge

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

hofff/contao-consent-bridge
===========================

Bridge between consent tools and third party extensions for Contao

1.8.0(1mo ago)26.6k16LGPL-3.0-or-laterPHPPHP ^8.2CI passing

Since Mar 25Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/hofff/contao-consent-bridge)[ Packagist](https://packagist.org/packages/hofff/contao-consent-bridge)[ GitHub Sponsors](https://github.com/dmolineus)[ RSS](/packages/hofff-contao-consent-bridge/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (15)Versions (18)Used By (6)

Bridge between consent tools and third party extensions for Contao
------------------------------------------------------------------

[](#bridge-between-consent-tools-and-third-party-extensions-for-contao)

This extension provides a bridge for integrating consent tools into Contao.

It's designed for consent tools which handles consent management on the client side but may require modified html output.

Requirements
------------

[](#requirements)

- Contao `^4.9`
- PHP `^7.1 || ^8.0`

Installation
------------

[](#installation)

You can install `hofff/contao-consent-bridge` using Composer/Contao Manager.

Changelog
---------

[](#changelog)

See [changelog](CHANGELOG.md)

Features
--------

[](#features)

- Provides activation for consent tools in root page
- Assign required consent ids for content elements and adjust output to fullfill requirements of consent tool
- Assign required consent ids for frontend modules and adjust output to fullfill requirements of consent tool
- Provides interface so that rendering for specific frontend templates can be adjusted to fullfill requirements of consent tools
- Built in support to google webfonts defined in the page layout
- Provides plugin infrastructure for extensions so that they are supported
- Provides interface for consent tools

Integration
-----------

[](#integration)

### As extension developer

[](#as-extension-developer)

If you provide an extension with custom content elements or frontend modules which might require consent to be rendered you can register a plugin which provides extra information. You need to tag it as `hofff_contao_consent_bridge.plugin`.

```
namespace Your\Bundle;

use Hofff\Contao\Consent\Bridge\Bridge;
use Hofff\Contao\Consent\Bridge\Bridge\Plugin;
use Hofff\Contao\Consent\Bridge\Render\RenderInformation;

class MyPlugin implements \Hofff\Contao\Consent\Bridge\Plugin
{
    public function load(Bridge $bridge): void
    {
        $bridge->supportFrontendModule('custom_1', RenderInformation::autoRenderWithoutPlaceholder());
        $bridge->supportFrontendModule('custom_2', RenderInformation::autoRenderWithPlaceholder('custom_placeholder_template'));
        $bridge->supportFrontendModule('custom_3', RenderInformation::customRender());

        $bridge->supportContentElement('custom_1', RenderInformation::autoRenderWithoutPlaceholder());
        $bridge->supportContentElement('custom_2', RenderInformation::autoRenderWithPlaceholder('custom_placeholder_template'));
        $bridge->supportContentElement('custom_3', RenderInformation::customRender());
    }
}
```

Then there will be a new legend where you can assign a consent id to your configuration, and the rendering of the HTML output will automatically adjust depending on the requirements of the consent tool.

### As consent tool developer

[](#as-consent-tool-developer)

As consent tool developer you need to implement the interface `Hofff\Contao\Consent\Bridge\ConsentTool` and tag it as `hofff_contao_consent_bridge.consent_tool` in the dependency injection container. Use the `\Hofff\Contao\Consent\Bridge\WithGenericContextSupport` interface if the consent tools should support twig.

### Twig integration

[](#twig-integration)

The extension provides Twig filters and functions to use consent functionality directly in Twig templates. The consent tool must implement `\Hofff\Contao\Consent\Bridge\WithGenericContextSupport` to support Twig rendering.

#### `hofff_consent_required` — Function

[](#hofff_consent_required--function)

Checks whether consent is required for a given consent ID. Returns `true` if the active consent tool requires consent, `false` otherwise (also when no consent tool is active or the ID is invalid).

```
{# Check by consent ID string #}
{% if hofff_consent_required('my-consent-id') %}
    {# Consent is required, render placeholder or alternative content #}
{% endif %}

{# Check using the Twig context (reads hofff_consent_bridge_tag automatically) #}
{% if hofff_consent_required(_context) %}
    {# Consent is required #}
{% endif %}
```

#### `hofff_consent_content` — Filter

[](#hofff_consent_content--filter)

Wraps HTML content according to the requirements of the active consent tool. If consent is required, the output is transformed by the consent tool (e.g. replaced with a placeholder). An optional custom placeholder template and additional data can be passed.

If no consent tool is active or the consent ID is invalid, the original HTML is returned unchanged.

```
{# Basic usage #}
{{ html_content|hofff_consent_content('my-consent-id') }}

{# With a custom placeholder template #}
{{ html_content|hofff_consent_content('my-consent-id', 'my_placeholder_template') }}

{# With a custom placeholder template and additional data passed to the consent tool #}
{{ html_content|hofff_consent_content('my-consent-id', 'my_placeholder_template', {title: 'My Title'}) }}
```

The filter can also be applied to larger blocks using the `{% apply %}` tag:

```
{% apply hofff_consent_content('my-consent-id') %}

{% endapply %}

{# With a custom placeholder template #}
{% apply hofff_consent_content('my-consent-id', 'my_placeholder_template') %}

{% endapply %}

{# With additional data #}
{% apply hofff_consent_content('my-consent-id', 'my_placeholder_template', {title: 'My Title'}) %}

{% endapply %}
```

#### `hofff_consent_raw` — Filter

[](#hofff_consent_raw--filter)

Applies consent requirements to raw HTML content (e.g. inline scripts or tracking code) without adding a visual placeholder. This is intended for hidden markup that should be managed by the consent tool but does not need a visible fallback.

If no consent tool is active or the consent ID is invalid, the original HTML is returned unchanged.

```
{# Basic usage #}
{{ raw_script|hofff_consent_raw('my-consent-id') }}

{# With additional data passed to the consent tool #}
{{ raw_script|hofff_consent_raw('my-consent-id', {key: 'value'}) }}
```

The filter can also be applied to blocks using the `{% apply %}` tag:

```
{% apply hofff_consent_raw('my-consent-id') %}

        // tracking code

{% endapply %}

{# With additional data #}
{% apply hofff_consent_raw('my-consent-id', {key: 'value'}) %}

        // tracking code

{% endapply %}
```

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance98

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~146 days

Recently: every ~137 days

Total

16

Last Release

46d ago

PHP version history (4 changes)1.0.0PHP ^7.1

1.4.0PHP ^7.1 || ^8.0

1.5.0PHP ^8.1

1.7.2PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef84f29864d94ca23f0adcec7922751ac34cda30f3bc9af45c90b92e11509e73?d=identicon)[frontendschlampe](/maintainers/frontendschlampe)

---

Top Contributors

[![dmolineus](https://avatars.githubusercontent.com/u/1186266?v=4)](https://github.com/dmolineus "dmolineus (129 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![richardhj](https://avatars.githubusercontent.com/u/1284725?v=4)](https://github.com/richardhj "richardhj (2 commits)")

---

Tags

cookiesconsentGDPDR

### Embed Badge

![Health badge](/badges/hofff-contao-consent-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/hofff-contao-consent-bridge/health.svg)](https://phpackages.com/packages/hofff-contao-consent-bridge)
```

###  Alternatives

[codefog/contao-news_categories

News Categories bundle for Contao Open Source CMS

3183.3k6](/packages/codefog-contao-news-categories)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.5k](/packages/numero2-contao-storelocator)[terminal42/contao-node

Node bundle for Contao Open Source CMS

3172.5k4](/packages/terminal42-contao-node)[oveleon/contao-cookiebar

Contao Cookiebar

63124.1k6](/packages/oveleon-contao-cookiebar)[contao-community-alliance/dc-general

Universal data container for Contao

1578.3k86](/packages/contao-community-alliance-dc-general)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
