Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net
| Property | Value |
|---|---|
| Composer package | mmd/oxid7-klaro-consent |
| Module ID | mmd_klaroconsent |
| Install path | source/modules/mmd/klaro-consent |
| Namespace | Mmd\KlaroConsent |
| Extended class | OxidEsales\Eshop\Core\ViewConfig |
| Events | onActivate creates the tables and the default service, onDeactivate does nothing |
| Controller ID | Class | Purpose |
|---|---|---|
mmd_klaro_service |
CookieServiceController |
Frame with list and edit view |
mmd_klaro_service_list |
CookieServiceList |
List of the current shop's services, deleting (not for required services) |
mmd_klaro_service_main |
CookieServiceMain |
Create and edit, title and description per language |
In menu.xml the menu entry mmd_klaro_consent ("Cookie Consent") hangs under the main menu mxcustnews (Customer Info). It points to the controller mmd_klaro_service with the list mmd_klaro_service_list and defines the tab mmd_klaro_service_main ("Edit Service").
ModuleEvents::onActivate creates both tables with CREATE TABLE IF NOT EXISTS.
mmd_klaro_cookie_service
| Column | Type | Meaning |
|---|---|---|
OXID |
CHAR(32) | Primary key |
OXSHOPID |
INT | Shop ID |
TECHNICAL_NAME |
VARCHAR(100) | Klaro name, unique together with OXSHOPID |
PURPOSE |
VARCHAR(50) | analytics, marketing, functional or security |
REQUIRED |
TINYINT(1) | Cannot be switched off |
DEFAULT_ENABLED |
TINYINT(1) | Preselected |
ACTIVE |
TINYINT(1) | Visible in the dialog |
COOKIES |
JSON | Deletion rules [{pattern, path, domain}] |
ONLY_ONCE |
TINYINT(1) | Execute only once |
CONTEXTUAL_CONSENT_ONLY |
TINYINT(1) | Release only via placeholder |
POSITION |
INT | Sort order |
OXTIMESTAMP |
TIMESTAMP | Modification time |
mmd_klaro_cookie_service_translation
| Column | Type | Meaning |
|---|---|---|
OXID |
CHAR(32) | Service, foreign key with ON DELETE CASCADE |
OXLANG |
INT | Language ID, 0 = German, 1 = English |
TITLE |
VARCHAR(255) | Display name |
DESCRIPTION |
TEXT | Description |
| Service | Purpose |
|---|---|
KlaroConfigBuilderInterface |
Builds the Klaro configuration from settings and services |
ModuleSettingsServiceInterface |
Typed access to the module settings, validates value ranges |
CookieServiceRepositoryInterface |
Reads and writes the services |
DefaultServicesInstaller |
Creates the service session |
The module extends ViewConfig. In Twig templates the following are available via oViewConf:
| Method | Returns |
|---|---|
isKlaroActive() |
Whether "Activate Cookie Consent" is on |
getKlaroConfigJson() |
Configuration as JSON, encoded with JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_HEX_QUOT. {} when the module is deactivated |
isGoogleConsentModeEnabled() |
Whether the consent mode option is on |
getKlaroPrimaryColor(), getKlaroSecondaryColor(), getKlaroDeclineColor() |
The color settings |
The file views/twig/extensions/themes/apex/layout/base.html.twig extends layout/base.html.twig in the blocks base_style and base_js. The widget @mmd_klaroconsent/widget/klaro_settings_link.html.twig lives under views/twig/widget.
KlaroConfigBuilder::buildConfig() returns these keys:
| Key | Value |
|---|---|
version |
1 |
elementID |
klaro |
storageMethod, storageName, cookieExpiresAfterDays |
from the storage settings |
privacyPolicy |
Privacy policy URL |
default |
always false |
mustConsent, acceptAll, hideDeclineAll, hideLearnMore, groupByPurpose |
from the behavior settings |
styling.theme |
Color theme plus position, with floating for bottom-left and bottom-right, otherwise with wide |
htmlTexts |
true |
services |
the shop's active services, sorted by sort order and name |
translations |
zz (fallback, German), de, en |
Each service entry contains name, purposes, required, default, onlyOnce, and optionally cookies and contextualConsentOnly.
| File | Content |
|---|---|
translations/{de,en}/mmd_klaroconsent_lang.php |
Storefront texts: dialog, purpose groups, buttons, footer link |
views/admin_twig/{de,en}/mmd_klaroconsent_lang.php |
Admin texts: menu, form fields, module settings |