Skip to content

Commit

Permalink
Merge pull request #1220 from danskernesdigitalebibliotek/DDFLSBP-651…
Browse files Browse the repository at this point in the history
…-implement-cookie-blocking-placeholder

DDFLSBP-651 - Implement cookie blocking placeholder
  • Loading branch information
Dresse authored Jun 17, 2024
2 parents 84b8f87 + 1025c25 commit 2a25172
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/sync/cookieinformation.settings.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enable_popup: false
enable_popup: true
google_consent_mode: ''
block_iframes: false
block_iframes_category: functional
Expand Down
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module:
dpl_breadcrumb: 0
dpl_cache_settings: 0
dpl_campaign: 0
dpl_cookies: 0
dpl_dashboard: 0
dpl_error_pages: 0
dpl_event: 0
Expand Down
7 changes: 7 additions & 0 deletions web/modules/custom/dpl_cookies/dpl_cookies.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "DPL Cookies"
type: module
description: "A module that handles cookie functionality."
package: DPL
core_version_requirement: ^10
dependencies:
- cookieinformation:cookieinformation
21 changes: 21 additions & 0 deletions web/modules/custom/dpl_cookies/dpl_cookies.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* @file
* DPL cookies module.
*/

/**
* Implements hook_preprocess_media().
*
* Adds cookie consent attributes to media video fields.
*/
function dpl_cookies_preprocess_field__media__video(array &$variables): void {
foreach ($variables['items'] as &$item) {
if (isset($item['content']['#attributes']['src'])) {
$item['content']['#attributes']['data-once'] = 'cookieinformation-iframe';
$item['content']['#attributes']['data-category-consent'] = 'cookie_cat_marketing';
$item['content']['#attributes']['data-consent-src'] = $item['content']['#attributes']['src'];
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% for item in items %}
{{ item.content }}
{% endfor %}

<div class="consent-placeholder cookie-placeholder cookie-placeholder__hide" data-category="cookie_cat_marketing">
<div class="pagefold-triangle--medium pagefold-inherit-parent"></div>
<div class="cookie-placeholder__wrapper">
<div class="cookie-placeholder__description">
<div id="dpl-react-apps-cookie-placeholder">
{{ "To view this content, we need your consent to use marketing cookies."|t({}, {"context": "Cookie Placeholder"}) }}
</div>
</div>
<button
type="button"
class="cookie-placeholder__manage-consent-button btn-primary btn-outline btn-xlarge arrow__hover--right-small"
aria-label="{{ 'Manage consent'|t({}, {'context': 'Cookie Placeholder'}) }}"
onClick="javascript:CookieConsent.renew();"
>
{{ "Manage consent"|t({}, {"context": "Cookie Placeholder"}) }}
</button>
</div>
</div>

0 comments on commit 2a25172

Please sign in to comment.