From 1871b5dc4e603b66d57a75b9d3b3485a01d79d07 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 06:25:17 +0200 Subject: [PATCH 01/14] Enabled dpl_cookies module --- config/sync/core.extension.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index e289750b86..29acd097a9 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -30,6 +30,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 From a2729b26469f041110239ae6c2f4ae348377e0bd Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 06:55:28 +0200 Subject: [PATCH 02/14] Enabled consent popup --- config/sync/cookieinformation.settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sync/cookieinformation.settings.yml b/config/sync/cookieinformation.settings.yml index 16f876d936..a3010e7f83 100644 --- a/config/sync/cookieinformation.settings.yml +++ b/config/sync/cookieinformation.settings.yml @@ -1,4 +1,4 @@ -enable_popup: false +enable_popup: true google_consent_mode: '' block_iframes: false block_iframes_category: functional From 508291820ba58fb4881914ec87d4a7aa00f13b42 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 07:06:30 +0200 Subject: [PATCH 03/14] Added dpl_cookies module. The purpose of the module is to handle all custom cookie functionality, that are not configurable in either the cookieinformation module or cookieinformation dashboard. For now I have added a single preprocessing function, that modifies all video media iFrames, adding new attributes that cookieinformation is used for handling cookies. --- .../custom/dpl_cookies/dpl_cookies.info.yml | 7 +++++++ .../custom/dpl_cookies/dpl_cookies.module | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 web/modules/custom/dpl_cookies/dpl_cookies.info.yml create mode 100644 web/modules/custom/dpl_cookies/dpl_cookies.module diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.info.yml b/web/modules/custom/dpl_cookies/dpl_cookies.info.yml new file mode 100644 index 0000000000..09e6fe20f3 --- /dev/null +++ b/web/modules/custom/dpl_cookies/dpl_cookies.info.yml @@ -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 diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.module b/web/modules/custom/dpl_cookies/dpl_cookies.module new file mode 100644 index 0000000000..ac74c6e68e --- /dev/null +++ b/web/modules/custom/dpl_cookies/dpl_cookies.module @@ -0,0 +1,17 @@ + Date: Wed, 5 Jun 2024 07:07:36 +0200 Subject: [PATCH 04/14] Added a new template for 'field--media--video' that adds a cookie placeholder to all video media elements. --- .../fields/field--media--video.html.twig | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 web/themes/custom/novel/templates/fields/field--media--video.html.twig diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig new file mode 100644 index 0000000000..f360ab3e82 --- /dev/null +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -0,0 +1,21 @@ +{% for item in items %} + {{ item.content }} +{% endfor %} + + From 104df4d56c873e946deac72d4cbf010c87960d17 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 07:15:09 +0200 Subject: [PATCH 05/14] mend --- .../novel/templates/fields/field--media--video.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig index f360ab3e82..9aca53a70e 100644 --- a/web/themes/custom/novel/templates/fields/field--media--video.html.twig +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -6,7 +6,7 @@ From 203ada2f20c6b1e7bbb9f6759e516dcb56ccdd67 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 07:23:58 +0200 Subject: [PATCH 06/14] Added context to translatable strings --- .../novel/templates/fields/field--media--video.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig index 9aca53a70e..3e2559c905 100644 --- a/web/themes/custom/novel/templates/fields/field--media--video.html.twig +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -6,7 +6,7 @@ From 0e48048a59076da610fc32efdc0228799206b801 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 07:28:37 +0200 Subject: [PATCH 07/14] mend --- .../novel/templates/fields/field--media--video.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig index 3e2559c905..d05463c404 100644 --- a/web/themes/custom/novel/templates/fields/field--media--video.html.twig +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -6,7 +6,7 @@ From b4cce8597be188f429b5a30a19c11b12682b2f6b Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 08:38:44 +0200 Subject: [PATCH 08/14] Made the preprocess hook more specific, as it was targeting other media fields than video --- web/modules/custom/dpl_cookies/dpl_cookies.module | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.module b/web/modules/custom/dpl_cookies/dpl_cookies.module index ac74c6e68e..0ee231a8d4 100644 --- a/web/modules/custom/dpl_cookies/dpl_cookies.module +++ b/web/modules/custom/dpl_cookies/dpl_cookies.module @@ -8,8 +8,10 @@ /** * Implements hook_preprocess_media(). */ -function dpl_cookies_preprocess_field__media(array &$variables): void { +function dpl_cookies_preprocess_field__media__video(array &$variables): void { foreach ($variables['items'] as &$item) { + + dpm($item); $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']; From 792eefea65fb0ae2c690ba8b349582099996d877 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 08:42:44 +0200 Subject: [PATCH 09/14] mend --- web/modules/custom/dpl_cookies/dpl_cookies.module | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.module b/web/modules/custom/dpl_cookies/dpl_cookies.module index 0ee231a8d4..e33a7aee86 100644 --- a/web/modules/custom/dpl_cookies/dpl_cookies.module +++ b/web/modules/custom/dpl_cookies/dpl_cookies.module @@ -10,8 +10,6 @@ */ function dpl_cookies_preprocess_field__media__video(array &$variables): void { foreach ($variables['items'] as &$item) { - - dpm($item); $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']; From c8259a1bbc089e96eed8bac3c69e9f66527cd053 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 09:03:31 +0200 Subject: [PATCH 10/14] Added check for 'src' attribute before setting up cookie data-attributes --- web/modules/custom/dpl_cookies/dpl_cookies.module | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.module b/web/modules/custom/dpl_cookies/dpl_cookies.module index e33a7aee86..79f4db2de8 100644 --- a/web/modules/custom/dpl_cookies/dpl_cookies.module +++ b/web/modules/custom/dpl_cookies/dpl_cookies.module @@ -10,8 +10,10 @@ */ function dpl_cookies_preprocess_field__media__video(array &$variables): void { foreach ($variables['items'] as &$item) { - $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']; + 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']; + } } } From 05da30db20b3907d1fcffa027de593d813975e83 Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Wed, 5 Jun 2024 13:50:39 +0200 Subject: [PATCH 11/14] Added description explaining the preprocess function. Also added translatable aria-label text --- web/modules/custom/dpl_cookies/dpl_cookies.module | 2 ++ .../novel/templates/fields/field--media--video.html.twig | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/modules/custom/dpl_cookies/dpl_cookies.module b/web/modules/custom/dpl_cookies/dpl_cookies.module index 79f4db2de8..d95a3f2010 100644 --- a/web/modules/custom/dpl_cookies/dpl_cookies.module +++ b/web/modules/custom/dpl_cookies/dpl_cookies.module @@ -7,6 +7,8 @@ /** * 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) { diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig index d05463c404..c4de928da4 100644 --- a/web/themes/custom/novel/templates/fields/field--media--video.html.twig +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -6,16 +6,16 @@ From 9266eb1d27fab0e3f33bef514dfffdf20ba63d2e Mon Sep 17 00:00:00 2001 From: Andreas Nielsen Date: Thu, 6 Jun 2024 14:08:59 +0200 Subject: [PATCH 12/14] Updated cookie consent placeholder template to match the design system by adding a pagefold div --- .../custom/novel/templates/fields/field--media--video.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/web/themes/custom/novel/templates/fields/field--media--video.html.twig b/web/themes/custom/novel/templates/fields/field--media--video.html.twig index c4de928da4..e41ed2f1e7 100644 --- a/web/themes/custom/novel/templates/fields/field--media--video.html.twig +++ b/web/themes/custom/novel/templates/fields/field--media--video.html.twig @@ -3,6 +3,7 @@ {% endfor %}